Class PrivContext

java.lang.Object
privbot.context.PrivContext

public final class PrivContext extends Object
Single entry point for scripts: hooks and timing helpers.

Sleep/timing utilities are on the Time class (static, Unethicalite-style). Thread-safe game access is handled by GameThread — hooks use it internally so scripts never need to think about threading.

Each field is a facade ("hook") over one area of the game. Reads marshal through GameThread.ensure(Supplier) and may return null, -1 or an empty result when the client cannot answer: unreadable is not a negative answer. Action verbs return true when the dispatch was accepted, which is not proof the action happened; confirm the state change with a later read. Blocking helpers (waits, travel) belong on the script worker, never on the client thread.

One instance per plugin injector (Singleton); the constructor also calls GameThread.init(net.runelite.api.Client, net.runelite.client.callback.ClientThread).

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final Actions
    Factories for worker-polled action-confirmation trackers; each plugin owns its own.
    final Bank
    Bank interface: open, withdraw, deposit and bank contents (ctx.bank).
    What the unified API supports on this server (privbot/api/capabilities.json).
    final Capture
    Passive recording to ~/.privbot/captures; writes nothing until start.
    final Chat
    Chatbox reads and sending chat lines or commands.
    final Combat
    Attacking, special attack and combat-state reads.
    final Dialogue
    Chat dialogues: continue, options and dialogue text.
    final Effects
    Creates plugin-owned effect trackers; event forwarding stays with the plugin lifecycle.
    final Equipment
    Worn items: snapshots, queries and counts.
    final Events
    Polling-backed typed events (projectile, hitsplat, animation, local death, graphic, var, chat).
    final Friends
    Friends list reads.
    final Game
    Game-wide state: login, tick count, instance, side tabs, run toggle, server name.
    Scene graphics objects (spot animations drawn in the world).
    Ground item queries and pickup (ctx.groundItems.query()).
    final Hazards
    Dodging: a hazard map plus the nearest reachable tile out of it.
    final Hotkeys
    Queued user key presses; start and stop with the plugin.
    final Ids
    OSRS id to this server's id (and back) for animations, graphics and varbits; empty when unknown.
    final Inventory
    Carried items: snapshots, counts and item actions (ctx.inventory).
    final Loadouts
    Equip an in-game loadout preset (Impact; unsupported elsewhere).
    final Loot
    Collects wanted ground items as a multi-tick Job, each pick proved by the inventory count.
    final Magic
    Spell casting.
    Run-scoped key-value scratchpad; not game state (see vars for that).
    final NPCs
    NPC queries and NPC interactions (ctx.npcs.query()).
    Scene object queries and interactions (ctx.objects.query()).
    final Places
    Named-location registry (banks, NPC anchors, areas) shared with travel.
    The local player as tri-state reads (name, tiles, animation, HP, interacting target).
    Other players in the scene.
    final Prayer
    Prayer state reads and prayer toggles.
    Production (make-X) interfaces for skilling.
    final Pvp
    A detached per-tick snapshot of a PvP fight (opponents' overheads, skulls, HP bars, animations, graphics, worn ids, tiles and targets), plus spell-effect trackers in this server's ids.
    final Recovery
    Death recovery (Impact reclaim; unsupported elsewhere).
    final Restock
    Go home and re-gear (Impact restockAtHome; Elorin RestockRunner; unsupported elsewhere).
    final Shop
    NPC shops: open and sell.
    final Skills
    Skill levels and experience.
    final Sustain
    Keeps hitpoints, prayer and stat boosts up (eat, brew, restore, dose), each consume proved by the count.
    final Targets
    Picking a target: a sticky lock over a snapshot's NPCs, and a safe way back to the live NPC.
    Teleport spells, tabs and item teleports.
    final Teleports
    Teleport to a named destination (Impact fairy trees; the movement catalog elsewhere).
    final Threats
    A detached per-tick snapshot of the fight (NPCs, projectiles, graphics, HP, chosen prayers) for the pure planners in privbot.mechanics.
    final Trade
    Player-to-player trade.
    final Travel
    Getting to a place: walking, transports and teleports.
    final User
    Local-player state: position, movement, animation, hitpoints, levels, overhead prayer.
    final Vars
    Raw varbit and varp reads.
    final Widgets
    Widget queries and widget clicks (ctx.widgets.query()).
    final Workflows
    Runs saved Builder workflows from a plugin (ctx.workflow.run(...)).
  • Method Summary

    Modifier and Type
    Method
    Description
    net.runelite.api.Client
    The client this context was built with.
    <T> T
    Runs fn on the client thread and returns the result.
    <T> T
    read(Supplier<T> observation)
    Batch a read-only decision in one client callback, reusing snapshots until it returns.
    void
    Runs r on the client thread (fire-and-forget); inline when already there.
    The server this client runs on, derived from the injected adapter.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • inventory

      public final Inventory inventory
      Carried items: snapshots, counts and item actions (ctx.inventory).
    • bank

      public final Bank bank
      Bank interface: open, withdraw, deposit and bank contents (ctx.bank).
    • npcs

      public final NPCs npcs
      NPC queries and NPC interactions (ctx.npcs.query()).
    • objects

      public final GameObjects objects
      Scene object queries and interactions (ctx.objects.query()).
    • graphics

      public final GraphicsObjects graphics
      Scene graphics objects (spot animations drawn in the world).
    • groundItems

      public final GroundItems groundItems
      Ground item queries and pickup (ctx.groundItems.query()).
    • equipment

      public final Equipment equipment
      Worn items: snapshots, queries and counts.
    • players

      public final PlayersHook players
      Other players in the scene.
    • prayer

      public final Prayer prayer
      Prayer state reads and prayer toggles.
    • combat

      public final Combat combat
      Attacking, special attack and combat-state reads.
    • skills

      public final Skills skills
      Skill levels and experience.
    • magic

      public final Magic magic
      Spell casting.
    • teleporter

      public final Teleporter teleporter
      Teleport spells, tabs and item teleports.
    • trade

      public final Trade trade
      Player-to-player trade.
    • shop

      public final Shop shop
      NPC shops: open and sell.
    • widgets

      public final Widgets widgets
      Widget queries and widget clicks (ctx.widgets.query()).
    • dialogue

      public final Dialogue dialogue
      Chat dialogues: continue, options and dialogue text.
    • user

      public final User user
      Local-player state: position, movement, animation, hitpoints, levels, overhead prayer.
    • game

      public final Game game
      Game-wide state: login, tick count, instance, side tabs, run toggle, server name.
    • chat

      public final Chat chat
      Chatbox reads and sending chat lines or commands.
    • friends

      public final Friends friends
      Friends list reads.
    • vars

      public final Vars vars
      Raw varbit and varp reads.
    • workflow

      public final Workflows workflow
      Runs saved Builder workflows from a plugin (ctx.workflow.run(...)).
    • places

      public final Places places
      Named-location registry (banks, NPC anchors, areas) shared with travel.
    • travel

      public final Travel travel
      Getting to a place: walking, transports and teleports. Blocking variants must run off the client thread.
    • production

      public final Production production
      Production (make-X) interfaces for skilling.
    • memory

      public final Blackboard memory
      Run-scoped key-value scratchpad; not game state (see vars for that).
    • effects

      public final Effects effects
      Creates plugin-owned effect trackers; event forwarding stays with the plugin lifecycle.
    • actions

      public final Actions actions
      Factories for worker-polled action-confirmation trackers; each plugin owns its own.
    • capabilities

      public final Capabilities capabilities
      What the unified API supports on this server (privbot/api/capabilities.json). A capability with no evidence is Support.UNKNOWN, never UNSUPPORTED.
    • ids

      public final Ids ids
      OSRS id to this server's id (and back) for animations, graphics and varbits; empty when unknown.
    • player

      public final LocalPlayer player
      The local player as tri-state reads (name, tiles, animation, HP, interacting target).
    • events

      public final Events events
      Polling-backed typed events (projectile, hitsplat, animation, local death, graphic, var, chat).
    • teleports

      public final Teleports teleports
      Teleport to a named destination (Impact fairy trees; the movement catalog elsewhere).
    • loadouts

      public final Loadouts loadouts
      Equip an in-game loadout preset (Impact; unsupported elsewhere).
    • restock

      public final Restock restock
      Go home and re-gear (Impact restockAtHome; Elorin RestockRunner; unsupported elsewhere).
    • recovery

      public final Recovery recovery
      Death recovery (Impact reclaim; unsupported elsewhere).
    • threats

      public final Threats threats
      A detached per-tick snapshot of the fight (NPCs, projectiles, graphics, HP, chosen prayers) for the pure planners in privbot.mechanics. Call from the runner worker or a node; it marshals its own read.
    • pvp

      public final Pvp pvp
      A detached per-tick snapshot of a PvP fight (opponents' overheads, skulls, HP bars, animations, graphics, worn ids, tiles and targets), plus spell-effect trackers in this server's ids. Call from the runner worker or a node.
    • hotkeys

      public final Hotkeys hotkeys
      Queued user key presses; start and stop with the plugin.
    • loot

      public final Loot loot
      Collects wanted ground items as a multi-tick Job, each pick proved by the inventory count.
    • sustain

      public final Sustain sustain
      Keeps hitpoints, prayer and stat boosts up (eat, brew, restore, dose), each consume proved by the count.
    • hazards

      public final Hazards hazards
      Dodging: a hazard map plus the nearest reachable tile out of it.
    • targets

      public final Targets targets
      Picking a target: a sticky lock over a snapshot's NPCs, and a safe way back to the live NPC.
    • capture

      public final Capture capture
      Passive recording to ~/.privbot/captures; writes nothing until start.
  • Method Details

    • server

      public ServerId server()
      The server this client runs on, derived from the injected adapter. UNKNOWN when undetected.
    • getClient

      public net.runelite.api.Client getClient()
      The client this context was built with. Raw client reads are not marshalled; wrap them in onClientThread(Supplier) or read(Supplier) when calling from a worker.
    • onClientThread

      public <T> T onClientThread(Supplier<T> fn)
      Runs fn on the client thread and returns the result. Delegates to GameThread.ensure(Supplier), so it runs inline when already on the client thread and returns null when the read was dropped (timeout, interrupt or exception).
    • read

      public <T> T read(Supplier<T> observation)
      Batch a read-only decision in one client callback, reusing snapshots until it returns. Opens a ReadScope; do not dispatch actions or wait inside it. Returns null when the read could not be served.
    • runOnClientThread

      public void runOnClientThread(Runnable r)
      Runs r on the client thread (fire-and-forget); inline when already there. Delegates to GameThread.invokeLater(Runnable).