浏览代码

Fix dupe bug

nossr50 4 年之前
父节点
当前提交
bec54d93ac

+ 6 - 2
Changelog.txt

@@ -1,6 +1,10 @@
 Version 2.1.167
-      Add McMMOPlayerPreXpGainEvent event for plugins to modify given exp
-      Add SkillActivationPerkEvent
+    Fixed a serious dupe bug
+    Add McMMOPlayerPreXpGainEvent event for plugins to modify given exp (thanks electronicboy)
+    Add SkillActivationPerkEvent (thanks electronicboy)
+
+    NOTE:
+    This bug was introduced in 2.1.165, update immediately if you are on 2.1.165 or 2.1.166
 
 
 Version 2.1.166

+ 4 - 1
src/main/java/com/gmail/nossr50/listeners/EntityListener.java

@@ -645,7 +645,10 @@ public class EntityListener implements Listener {
     @EventHandler(ignoreCancelled = true)
     public void onEntityDeath(EntityDeathEvent event) {
         LivingEntity entity = event.getEntity();
-        mcMMO.getTransientEntityTracker().removeSummon(entity, null, false);
+
+        if(mcMMO.getTransientEntityTracker().isTransientSummon(entity)) {
+            mcMMO.getTransientEntityTracker().removeSummon(entity, null, false);
+        }
 
         /* WORLD BLACKLIST CHECK */
         if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) {

+ 10 - 0
src/main/java/com/gmail/nossr50/util/TransientEntityTracker.java

@@ -124,6 +124,16 @@ public class TransientEntityTracker {
         addToChunkLookupCache(trackedTamingEntity);
     }
 
+    /**
+     * Checks if a living entity is a summon
+     *
+     * @param livingEntity target livinig entity
+     * @return true if target living entity is a summon
+     */
+    public synchronized boolean isTransientSummon(@NotNull LivingEntity livingEntity) {
+        return getChunkLookupCache().contains(livingEntity);
+    }
+
     /**
      * Get the tracked taming entities for a player
      * If the player isn't registered this will return null