Skip to content

Commit

Permalink
Simplify skinupdatetracker
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Feb 11, 2023
1 parent dddabd1 commit 142931a
Showing 1 changed file with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.common.base.Preconditions;
import com.google.common.base.Predicates;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;

import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.CitizensAPI;
Expand Down Expand Up @@ -170,6 +171,7 @@ private PlayerTracker getTracker(Player player, boolean reset) {
*/
public void onNPCDespawn(NPC npc) {
Preconditions.checkNotNull(npc);
playerTrackers.remove(npc.getUniqueId());
SkinnableEntity skinnable = getSkinnable(npc);
if (skinnable == null)
return;
Expand Down Expand Up @@ -268,16 +270,8 @@ public void removePlayer(UUID playerId) {
* </p>
*/
public void reset() {
for (Player player : Bukkit.getOnlinePlayers()) {
if (player.hasMetadata("NPC"))
continue;

PlayerTracker tracker = playerTrackers.get(player.getUniqueId());
if (tracker == null)
continue;

tracker.hardReset(player);
}
navigating.clear();
playerTrackers.clear();
}

// hard reset players near a skinnable NPC
Expand Down Expand Up @@ -342,7 +336,9 @@ public void run() {
return;

List<SkinnableEntity> nearby = new ArrayList<SkinnableEntity>(10);
Set<UUID> seen = Sets.newHashSet();
for (Player player : Bukkit.getOnlinePlayers()) {
seen.add(player.getUniqueId());
if (player.hasMetadata("NPC"))
continue;

Expand All @@ -356,6 +352,7 @@ public void run() {

nearby.clear();
}
playerTrackers.keySet().removeIf(uuid -> !seen.contains(uuid));
}
}

Expand Down

0 comments on commit 142931a

Please sign in to comment.