Check world first in skin trackers

This commit is contained in:
fullwall 2023-02-10 21:13:32 +08:00
parent fe4434de91
commit 41ca21a131

View File

@ -342,9 +342,7 @@ public class SkinUpdateTracker {
return; return;
List<SkinnableEntity> nearby = new ArrayList<SkinnableEntity>(10); List<SkinnableEntity> nearby = new ArrayList<SkinnableEntity>(10);
Collection<? extends Player> players = Bukkit.getOnlinePlayers(); for (Player player : Bukkit.getOnlinePlayers()) {
for (Player player : players) {
if (player.hasMetadata("NPC")) if (player.hasMetadata("NPC"))
continue; continue;
@ -417,6 +415,12 @@ public class SkinUpdateTracker {
boolean shouldUpdate(Player player) { boolean shouldUpdate(Player player) {
Location currentLoc = player.getLocation(CACHE_LOCATION); Location currentLoc = player.getLocation(CACHE_LOCATION);
// make sure player is in same world
if (!currentLoc.getWorld().equals(this.location.getWorld())) {
hardReset(player);
return true;
}
if (!hasMoved) { if (!hasMoved) {
hasMoved = true; hasMoved = true;
return true; return true;
@ -440,12 +444,6 @@ public class SkinUpdateTracker {
} }
} }
// make sure player is in same world
if (!currentLoc.getWorld().equals(this.location.getWorld())) {
reset(player);
return true;
}
// update every time a player moves a certain distance // update every time a player moves a certain distance
if (currentLoc.distance(this.location) > MOVEMENT_SKIN_UPDATE_DISTANCE) { if (currentLoc.distance(this.location) > MOVEMENT_SKIN_UPDATE_DISTANCE) {
reset(player); reset(player);
@ -467,7 +465,7 @@ public class SkinUpdateTracker {
} }
private static final Location CACHE_LOCATION = new Location(null, 0, 0, 0); private static final Location CACHE_LOCATION = new Location(null, 0, 0, 0);
private static final float FIELD_OF_VIEW = 70f; private static final float FIELD_OF_VIEW = 70F;
private static final int MOVEMENT_SKIN_UPDATE_DISTANCE = 25; private static final int MOVEMENT_SKIN_UPDATE_DISTANCE = 25;
private static final Location NPC_LOCATION = new Location(null, 0, 0, 0); private static final Location NPC_LOCATION = new Location(null, 0, 0, 0);
} }