Class Game

java.lang.Object
privbot.hooks.Game

public final class Game extends Object
Session and client state: ctx.game (server, login, tick, tabs, instance, run mode).

The observed* reads and tick() keep "cannot read" apart; the primitive reads answer a default for it (see each method).

  • Method Details

    • currentTab

      public String currentTab()
      The selected profile-backed tab name, or null when the tab cannot be read.
    • openTab

      public boolean openTab(String name)
      Open a named side tab. Acceptance is confirmed by a subsequent currentTab() read.
    • getServerName

      public String getServerName()
      Returns:
      the server's display name ("Elorin", "Impact"), or "" without an adapter
    • isLoggedIn

      public boolean isLoggedIn()
      Returns:
      the adapter's logged-in read
    • getTickCount

      public int getTickCount()
      The game's tick counter, or -1 when the read cannot be served.

      GameThread.ensure(java.util.function.Supplier<T>, T) answers null when it drops a read rather than guessing - a stalled render loop, a two-second marshal that did not complete. This method returned that Integer as an int, so an unreadable clock did not read as unknown: it threw a NullPointerException. In a workflow that exception surfaced as "Phase 'Main': condition error: null", the stage was skipped, and a flow whose only rule was gated on a timer parked for the whole session without ever acting.

      Callers doing tick arithmetic should treat a negative answer as "unknown" rather than as a tick number.

    • isInInstance

      public boolean isInInstance()
      Returns:
      whether the client reports an instanced region; false when unreadable (see observedInInstance())
    • observedInInstance

      public Boolean observedInInstance()
      Observed instance state, or null when its mapped field/read is unavailable.
    • observedRunEnabled

      public Boolean observedRunEnabled()
      Observed run mode, or null when its mapped field/read is unavailable.
    • observedRunEnergy

      public Integer observedRunEnergy()
      Observed run energy in percent (0..100), or null when unavailable or invalid.
    • isRunEnabled

      public boolean isRunEnabled()
      Returns:
      whether run is on; false when unreadable (see observedRunEnabled())
    • setRun

      public void setRun(boolean enabled)
      Toggles run when the current state is readable and differs, by clicking this server's run orb. Does nothing when the state cannot be read. Verify with observedRunEnabled().
      Parameters:
      enabled - the wanted state
    • getRunEnergy

      public int getRunEnergy()
      Returns:
      run energy 0..100; 0 when unreadable (see observedRunEnergy())
    • tick

      public Observed<Integer> tick()
      The game's tick counter (one per 600 ms server tick), with "cannot read" kept apart: getTickCount() answers -1 for that, which tick arithmetic easily mistakes for a number.

      On Impact, Elorin and SpawnPK it counts the client's own ticks (on Impact, derived from the game cycle), not the server-aligned GameTick events a plugin receives; use it for elapsed-tick arithmetic, not as an id shared with another client.

      Returns:
      the current tick count; UNREADABLE when the read was dropped or the client has none
    • observedTicksSince

      public Observed<Integer> observedTicksSince(int earlierTick)
      Ticks elapsed since earlierTick (a value an earlier tick() returned).
      Parameters:
      earlierTick - a tick read earlier; negative means "never recorded"
      Returns:
      the elapsed ticks; UNREADABLE when the current tick cannot be read or earlierTick is negative
    • ticksSince

      public int ticksSince(int earlierTick)
      Primitive form of observedTicksSince(int): the elapsed ticks, or -1 when unknown. Treat a negative answer as "unknown", never as "no time passed".
      Parameters:
      earlierTick - a tick read earlier; negative means "never recorded"
      Returns:
      elapsed ticks, or -1