Get around expensive validate calls (#2318)

This commit is contained in:
LOOHP 2023-04-10 05:40:57 +08:00 committed by GitHub
parent ab32f938d7
commit d83dd9ab8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -178,7 +178,9 @@ class EntityUtilities {
Validate.notNull(entity, "entity cannot be null");
Object trackerEntry = this.getEntityTrackerEntry(entity.getWorld(), entity.getEntityId());
Validate.notNull(trackerEntry, "Could not find entity trackers for " + entity);
if (trackerEntry == null) { //entity.toString() is too expensive to be called every time
throw new IllegalArgumentException("Could not find entity trackers for " + entity);
}
if (this.trackedPlayersField == null) {
this.trackedPlayersField = Accessors.getFieldAccessor(