Class PlayersHook

java.lang.Object
privbot.hooks.PlayersHook
All Implemented Interfaces:
PlayerSearch.Source

public final class PlayersHook extends Object implements PlayerSearch.Source
Thin wrapper so PrivContext exposes players via injected Client.
  • Method Details

    • getPlayers

      public List<net.runelite.api.Player> getPlayers()
      Returns the raw player list. Prefer query() for filtering; this exists so plugins can replace direct client.getPlayers() calls without rewriting iteration logic.
    • closest

      public net.runelite.api.Player closest(Predicate<net.runelite.api.Player> pred)
      Parameters:
      pred - the test
      Returns:
      the closest loaded player that matches, or null
    • closest

      public PrivPlayer closest(String... names)
      Closest other player matching any of the supplied names, or null. Matches names case-insensitively (contains) and excludes the local player. Empty or null names still exclude local and return the nearest other player.
    • nearest

      public PrivPlayer nearest(String... names)
    • exists

      public boolean exists(String... names)
      Whether another player matching any of the supplied names is currently loaded.
    • interact

      public boolean interact(String name, String action)
      Interacts with the closest other player matching name using action. Name then action. Returns false when the name/action is blank or nobody matched.
    • closestPriv

      public PrivPlayer closestPriv(Predicate<net.runelite.api.Player> pred)
      Nearest matching player as a PrivPlayer for menu dispatch.
    • wrap

      public PrivPlayer wrap(net.runelite.api.Player player)
      Parameters:
      player - a player object (may be null)
      Returns:
      the wrapper with this context's adapter, or null
    • nearest

      public static net.runelite.api.Player nearest(Predicate<net.runelite.api.Player> pred)
      Nearest player matching the predicate.
    • bountyTarget

      public String bountyTarget()
      The current Bounty Hunter target's display name (tags and colour codes removed), or null when none is assigned or the server offers no readable source. Check bountyTargetReadable() before treating null as "no target".
    • bountyTargetReadable

      public boolean bountyTargetReadable()
      True when this server/profile exposes the Bounty Hunter target at all.
    • cleanBountyTarget

      public static String cleanBountyTarget(String raw)
      Normalised target name; blank, "null" and "None" (the overlay's empty spellings) are no target.
    • normalizeRsName

      public static String normalizeRsName(String raw)
      Strips colour/icon tags and normalises spaces (including the non-breaking space RS names use).
      Parameters:
      raw - a name as the client shows it
      Returns:
      the plain name ("" for null)