Skip to content

Commit

Permalink
Add playerfilter run
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Apr 17, 2023
1 parent bfcdea3 commit 8783b24
Showing 1 changed file with 8 additions and 1 deletion.
Expand Up @@ -13,6 +13,7 @@

import com.google.common.collect.Sets;

import net.citizensnpcs.api.npc.NPC.NPCUpdate;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
Expand Down Expand Up @@ -130,7 +131,6 @@ public boolean onSeenByPlayer(Player player) {
* that should no longer view the NPC.
*/
public void recalculate() {
System.out.println(viewingPlayers + " " + hiddenPlayers);
for (Iterator<UUID> itr = viewingPlayers.iterator(); itr.hasNext();) {
UUID uuid = itr.next();
Player player = Bukkit.getPlayer(uuid);
Expand All @@ -157,6 +157,13 @@ public void recalculate() {
}
}

@Override
public void run() {
if (!npc.isSpawned() || !npc.isUpdating(NPCUpdate.PACKET))
return;
recalculate();
}

/**
* Sets the filter function, which returns {@code true} if the {@link NPC} should be hidden from the given
* {@link Player}.
Expand Down

0 comments on commit 8783b24

Please sign in to comment.