Class Player

java.lang.Object
com.botwithus.bot.api.entities.Player
All Implemented Interfaces:
EntityContext

public final class Player extends Object implements EntityContext
Rich wrapper around a snapshot Player record. Players don't have a per-id type definition the way NPCs do — what would be on NpcType (name, options, ...) is per-instance and lives in the snapshot or arrives as packets — so this wrapper is thinner than Npc.

Name collision note: the snapshot type com.botwithus.bot.api.snapshot.Player shares the simple name Player with this wrapper, so the snapshot type is fully qualified at the field declaration below and reflected mechanically on the constructor parameter and raw() accessor (Java has no import aliasing, and the enclosing class shadows any import of the snapshot type).

  • Method Details

    • raw

      public Player raw()
    • serverIndex

      public int serverIndex()
    • combatLevel

      public int combatLevel()
    • followingIndex

      public int followingIndex()
    • animationId

      public int animationId()
    • stanceId

      public int stanceId()
    • isMoving

      public boolean isMoving()
    • spotAnimId

      public int spotAnimId()
      First active spot anim (graphic) id playing on this player, or -1 if none. Only the first concurrent spot anim is surfaced — subscribe to SpotAnimEvent for every newly-started one.
    • orientation

      public Orientation orientation()
      Which way this player is facing (wire v21): its rendered facing, interpolated while it turns. Use Orientation.compass() or Orientation.degrees() to read it, and Orientation.isSameFacingAs(Orientation) to compare two, never equals; the client can read an angle back one unit short. Unknown when the producer could not read one.
    • tileX

      public int tileX()
      Description copied from interface: EntityContext
      Absolute world tile X.
      Specified by:
      tileX in interface EntityContext
    • tileY

      public int tileY()
      Description copied from interface: EntityContext
      Absolute world tile Y.
      Specified by:
      tileY in interface EntityContext
    • plane

      public int plane()
      Description copied from interface: EntityContext
      Plane / height level (0-3).
      Specified by:
      plane in interface EntityContext
    • distanceToPlayer

      public int distanceToPlayer()
      Chebyshev distance to the local player tile, or MAX_VALUE if the local player isn't loaded.
    • interact

      public void interact(int optionIndex)
      Queue an action against this player by 1-based option index.
      Throws:
      IllegalArgumentException - for optionIndex outside [1, 10]
    • toString

      public String toString()
      Overrides:
      toString in class Object