Class PrivPlayer

java.lang.Object
privbot.wrappers.PrivPlayer

public final class PrivPlayer extends Object
Other-player wrapper. Attack and Trade route through the proven per-server paths (ctx.combat and Trade.request(privbot.wrappers.PrivPlayer)); other options use the game client with the server-correct player identifier (raw getId() on Impact, compacted list index elsewhere).

RuneLite does not expose a player menu composition, so hasAction(String) / interact(String) use a best-effort synonym table for common OSRS menu slots (0–7). Use interactSlot(int) when you know the exact option index.

  • Method Details

    • getPlayer

      public net.runelite.api.Player getPlayer()
      The wrapped client player (may be null). Raw reads on it are not marshalled.
    • getName

      public String getName()
      The player's name as the client reports it (tags not stripped), or empty when unknown.
    • getId

      public int getId()
      The client's player id, or -1. On Impact and Elorin this is the player's slot in the client's own player array, which is what player menu actions send.
    • getIndex

      public int getIndex()
      Live player-list index used as the identifier in Impact player actions.

      Note: this is the position in the null-compacted client.getPlayers() list, which differs from the player's slot in the client's own player array in a busy world. Player menu actions on Impact and Elorin use getId() instead. -1 when the player is not in the list.

    • getCombatLevel

      public int getCombatLevel()
      The client's combat-level field, or -1 without a player. Caution: on Impact the mapped field has held the server player id rather than the displayed level (trade requests rely on it), so do not treat it as a level there.
    • getWorldLocation

      public net.runelite.api.coords.WorldPoint getWorldLocation()
      The player's current world tile, or null when unknown.
    • distanceTo

      public double distanceTo(net.runelite.api.coords.WorldPoint p)
      Tile-step distance to p. Integer.MAX_VALUE on different planes, Double.MAX_VALUE when either location is unknown.
    • exists

      public boolean exists()
      True if this Player instance is still in Client.getPlayers().
    • hasAction

      public boolean hasAction(String action)
      Best-effort: whether interact(String) can map action to a menu slot via KNOWN_SYNONYMS. Not read from the client (no API for other players' menus).
    • interact

      public boolean interact(String action)
      Dispatches a player option, marshalled through GameThread.ensure(java.util.function.Supplier<T>, T). Attack and (on Impact, Elorin and SpawnPK) Trade/Follow use the per-server paths; other labels map to a menu slot through a synonym table (see hasAction(String)).
      Returns:
      true when the action was dispatched, not proof it happened; false when the label has no mapping, the player cannot be identified, or the call was dropped
    • interactSlot

      public boolean interactSlot(int menuSlot)
      Parameters:
      menuSlot - 0-based player menu option index (0 = first option, matches the first player option).