Browse Source

Ignore "fake player" npcs in EntityPickupItemEvent

nossr50 4 years ago
parent
commit
8ee405fbfd
2 changed files with 7 additions and 4 deletions
  1. 1 0
      Changelog.txt
  2. 6 4
      src/main/java/com/gmail/nossr50/listeners/PlayerListener.java

+ 1 - 0
Changelog.txt

@@ -7,6 +7,7 @@ Version 2.1.165
     mcMMO will now be compatible with changes to world height (1.17 compatibility)
     mcMMO will now be compatible with changes to world height (1.17 compatibility)
     Added missing cooldown locale message 'Commands.Database.Cooldown'
     Added missing cooldown locale message 'Commands.Database.Cooldown'
     Added new locale message 'Taming.Summon.COTW.Removed'
     Added new locale message 'Taming.Summon.COTW.Removed'
+    mcMMO will ignore PlayerPickupItem events from "Fake-Player" NPCs if it recognizes them as such, this will prevent some issues
 
 
     NOTES:
     NOTES:
     Books dropped before this fix will not be usable and should just be chucked in lava, the broken books have blue names, the working books have yellow names.
     Books dropped before this fix will not be usable and should just be chucked in lava, the broken books have blue names, the working books have yellow names.

+ 6 - 4
src/main/java/com/gmail/nossr50/listeners/PlayerListener.java

@@ -447,6 +447,10 @@ public class PlayerListener implements Listener {
         if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
         if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
             return;
             return;
 
 
+        if(Misc.isNPCEntityExcludingVillagers(event.getEntity())) {
+            return;
+        }
+
         if(event.getEntity() instanceof Player)
         if(event.getEntity() instanceof Player)
         {
         {
             Player player = (Player) event.getEntity();
             Player player = (Player) event.getEntity();
@@ -463,13 +467,11 @@ public class PlayerListener implements Listener {
             }
             }
 
 
             //Profile not loaded
             //Profile not loaded
-            if(UserManager.getPlayer(player) == null)
-            {
+            McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
+            if(mcMMOPlayer == null) {
                 return;
                 return;
             }
             }
 
 
-            McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
-
             Item drop = event.getItem();
             Item drop = event.getItem();
             ItemStack dropStack = drop.getItemStack();
             ItemStack dropStack = drop.getItemStack();