diff --git a/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/EntityUtilities.java b/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/EntityUtilities.java index 36a71f5a..e326a20e 100644 --- a/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/EntityUtilities.java +++ b/modules/ProtocolLib/src/main/java/com/comphenix/protocol/injector/EntityUtilities.java @@ -63,10 +63,14 @@ class EntityUtilities { */ public static void updateEntity(Entity entity, List observers) throws FieldAccessException { + if (entity == null || !entity.isValid()) { + return; + } + try { Object trackerEntry = getEntityTrackerEntry(entity.getWorld(), entity.getEntityId()); if (trackerEntry == null) { - throw new IllegalArgumentException("Cannot find entity trackers for " + entity + (entity.isDead() ? " - entity is dead." : ".")); + throw new IllegalArgumentException("Cannot find entity trackers for " + entity + "."); } if (trackedPlayersField == null) { @@ -106,12 +110,16 @@ class EntityUtilities { * @throws FieldAccessException If reflection failed. */ public static List getEntityTrackers(Entity entity) { + if (entity == null || !entity.isValid()) { + return new ArrayList<>(); + } + try { List result = new ArrayList(); Object trackerEntry = getEntityTrackerEntry(entity.getWorld(), entity.getEntityId()); if (trackerEntry == null) { - throw new IllegalArgumentException("Cannot find entity trackers for " + entity + (entity.isDead() ? " - entity is dead." : ".")); + throw new IllegalArgumentException("Cannot find entity trackers for " + entity + "."); } if (trackedPlayersField == null) { @@ -230,7 +238,6 @@ class EntityUtilities { } private static List unwrapBukkit(List players) { - List output = Lists.newArrayList(); BukkitUnwrapper unwrapper = new BukkitUnwrapper();