@@ -63,10 +63,14 @@ public static void updateEntity2(Entity entity, List<Player> observers) {
63
63
*/
64
64
65
65
public static void updateEntity (Entity entity , List <Player > observers ) throws FieldAccessException {
66
+ if (entity == null || !entity .isValid ()) {
67
+ return ;
68
+ }
69
+
66
70
try {
67
71
Object trackerEntry = getEntityTrackerEntry (entity .getWorld (), entity .getEntityId ());
68
72
if (trackerEntry == null ) {
69
- throw new IllegalArgumentException ("Cannot find entity trackers for " + entity + ( entity . isDead () ? " - entity is dead." : "." ) );
73
+ throw new IllegalArgumentException ("Cannot find entity trackers for " + entity + "." );
70
74
}
71
75
72
76
if (trackedPlayersField == null ) {
@@ -106,12 +110,16 @@ public static void updateEntity(Entity entity, List<Player> observers) throws Fi
106
110
* @throws FieldAccessException If reflection failed.
107
111
*/
108
112
public static List <Player > getEntityTrackers (Entity entity ) {
113
+ if (entity == null || !entity .isValid ()) {
114
+ return new ArrayList <>();
115
+ }
116
+
109
117
try {
110
118
List <Player > result = new ArrayList <Player >();
111
119
112
120
Object trackerEntry = getEntityTrackerEntry (entity .getWorld (), entity .getEntityId ());
113
121
if (trackerEntry == null ) {
114
- throw new IllegalArgumentException ("Cannot find entity trackers for " + entity + ( entity . isDead () ? " - entity is dead." : "." ) );
122
+ throw new IllegalArgumentException ("Cannot find entity trackers for " + entity + "." );
115
123
}
116
124
117
125
if (trackedPlayersField == null ) {
@@ -230,7 +238,6 @@ public static Entity getEntityFromID(World world, int entityID) throws FieldAcce
230
238
}
231
239
232
240
private static List <Object > unwrapBukkit (List <Player > players ) {
233
-
234
241
List <Object > output = Lists .newArrayList ();
235
242
BukkitUnwrapper unwrapper = new BukkitUnwrapper ();
236
243
0 commit comments