Class PlayerFilter

java.lang.Object
net.citizensnpcs.api.trait.Trait
net.citizensnpcs.api.trait.trait.PlayerFilter
All Implemented Interfaces:
Runnable, Listener

public class PlayerFilter extends Trait
  • Constructor Details

  • Method Details

    • addChildNPC

      public void addChildNPC(NPC npc)
    • addGroup

      public void addGroup(String group)
      Hides the NPC from the given permissions group
    • addPlayer

      public void addPlayer(UUID uuid)
      Hides the NPC from the given Player UUID.
      Parameters:
      uuid -
    • affectsGroup

      public boolean affectsGroup(String group)
    • affectsPlayer

      public boolean affectsPlayer(UUID uuid)
    • clear

      public void clear()
      Clears all set UUID filters.
    • getApplyRange

      public double getApplyRange()
    • getGroups

      public Set<String> getGroups()
      Implementation detail: may change in the future.
    • getPlayerUUIDs

      public Set<UUID> getPlayerUUIDs()
      Implementation detail: may change in the future.
    • isAllowlist

      public boolean isAllowlist()
    • isDenylist

      public boolean isDenylist()
    • isHidden

      public boolean isHidden(Player player)
      Whether the NPC should be hidden from the given Player
    • onDespawn

      public void onDespawn()
      Description copied from class: Trait
      Called just before the attached NPC is despawned. NPC.getEntity() will be non-null.
      Overrides:
      onDespawn in class Trait
    • onSeenByPlayer

      public boolean onSeenByPlayer(Player player)
      For internal use. Method signature may be changed at any time.
    • recalculate

      public void recalculate()
      Explicit recalculation of which Players should be viewing the NPC. Sends hide packets for players that should no longer view the NPC.
    • removeGroup

      public void removeGroup(String group)
      Unhides the given permissions group
    • removePlayer

      public void removePlayer(UUID uuid)
      Unhides the given Player UUID
    • run

      public void run()
      Description copied from class: Trait
      Called every tick if overridden.
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Trait
    • setAllowlist

      public void setAllowlist()
    • setApplyRange

      public void setApplyRange(double range)
      Sets the range in blocks where the filter applies. For example, if the range is 25 blocks and the Player is more than 25 blocks away, the filter is ignored and the Player will not be hidden.
      Parameters:
      range - The new range
    • setDenylist

      public void setDenylist()
      Implementation detail: may change in the future.
    • setPlayerFilter

      public void setPlayerFilter(Function<Player,Boolean> filter)
      Sets the filter function, which returns true if the NPC should be hidden from the given Player.
    • setPlayers

      public void setPlayers(Set<UUID> players)
      Implementation detail: may change in the future.