Skip to content

Commit

Permalink
More descriptive error message when an entities tracker is not found.
Browse files Browse the repository at this point in the history
  • Loading branch information
aadnk committed Sep 15, 2013
1 parent bed74f6 commit 4e2af45
Showing 1 changed file with 7 additions and 2 deletions.
Expand Up @@ -132,9 +132,14 @@ public static List<Player> getEntityTrackers(Entity entity) {
List<Player> result = new ArrayList<Player>();
Object trackerEntry = getEntityTrackerEntry(entity.getWorld(), entity.getEntityId());

if (trackedPlayersField == null)
if (trackerEntry == null) {
throw new IllegalArgumentException("Cannot find entity trackers for " + entity +
(entity.isDead() ? " - entity is dead." : "."));
}
if (trackedPlayersField == null) {
trackedPlayersField = FuzzyReflection.fromObject(trackerEntry).getFieldByType("java\\.util\\..*");

}

Collection<?> trackedPlayers = (Collection<?>) FieldUtils.readField(trackedPlayersField, trackerEntry, false);

// Wrap every player - we also ensure that the underlying tracker list is immutable
Expand Down

0 comments on commit 4e2af45

Please sign in to comment.