Class Game

java.lang.Object
org.rspeer.game.Game

public class Game extends Object
Provides general game state operations
  • Field Details

    • STATE_LOADING_GAME

      public static final int STATE_LOADING_GAME
      Represents the game state during loading.
      See Also:
    • STATE_CREDENTIALS_SCREEN

      public static final int STATE_CREDENTIALS_SCREEN
      Represents the state of the credentials screen.
      See Also:
    • STATE_AUTHENTICATOR_SCREEN

      public static final int STATE_AUTHENTICATOR_SCREEN
      Represents the state of the authenticator screen.
      See Also:
    • STATE_LOGGING_IN

      public static final int STATE_LOGGING_IN
      Represents the game state during the login process.
      See Also:
    • STATE_LOADING_REGION

      public static final int STATE_LOADING_REGION
      Represents the game state while loading a region.
      See Also:
    • STATE_IN_GAME

      public static final int STATE_IN_GAME
      Represents the state when the player is in-game.
      See Also:
    • STATE_CONNECTION_LOST

      public static final int STATE_CONNECTION_LOST
      Represents the state when the connection is lost.
      See Also:
    • STATE_HOPPING_WORLD

      public static final int STATE_HOPPING_WORLD
      Represents the state during world hopping.
      See Also:
    • STATE_COMPLETING_WORLD_TRANSFER

      public static final int STATE_COMPLETING_WORLD_TRANSFER
      Represents the state during the second part of world hopping.
      See Also:
  • Constructor Details

    • Game

      public Game()
  • Method Details

    • getClient

      public static jag.oldscape.RSClient getClient()
    • setFps

      public static void setFps(int fps)
    • getTick

      @Deprecated public static int getTick()
      Deprecated.
      Returns:
      Note: This method should NOT be used for your own timers. The game seems to randomly reset this value so it should only be used in conjunction with values that align with it, such as varp/varc values
    • getServerTick

      public static int getServerTick()
      Returns:
      Note: This method should NOT be used for your own timers. The game seems to randomly reset this value so it should only be used in conjunction with values that align with it, such as varp/varc values
    • getTickCount

      public static int getTickCount()
    • setTickCount

      public static void setTickCount(int tickCount)
    • getTopLevelMatrixId

      public static int getTopLevelMatrixId()
    • getTopLevelMatrix

      public static jag.oldscape.RSWorldMatrix getTopLevelMatrix()
    • getLocalMatrix

      public static jag.oldscape.RSWorldMatrix getLocalMatrix()
    • getMatrix

      public static jag.oldscape.RSWorldMatrix getMatrix(int id)
    • getWorldEntity

      public static WorldEntity getWorldEntity(jag.oldscape.RSWorldMatrix matrix)
    • getWorldEntity

      public static WorldEntity getWorldEntity(int id)
    • getMatrixAt

      public static jag.oldscape.RSWorldMatrix getMatrixAt(Coord coord)
    • getLoadedMatrixes

      public static List<jag.oldscape.RSWorldMatrix> getLoadedMatrixes()
    • getRemainingMembershipDays

      public static int getRemainingMembershipDays()
    • isMembershipPresent

      public static boolean isMembershipPresent()
    • logout

      public static boolean logout()
    • logout

      public static boolean logout(boolean direct)
      Parameters:
      direct - true indicates to instantly log out by setting the clients main state. false means to use the logout button in game
      Returns:
      true if an attempt was made to log out
    • getAccountType

      public static AccountType getAccountType()
    • addMouseListener

      @Deprecated public static void addMouseListener(BotMouseListener listener)
      Deprecated.
      See Also:
    • removeMouseListener

      @Deprecated public static void removeMouseListener(BotMouseListener listener)
      Deprecated.
      See Also:
    • getMouseListeners

      @Deprecated public static List<BotMouseListener> getMouseListeners()
      Deprecated.
      See Also:
    • queueAction

      public static void queueAction(MenuAction action)
    • queueAction

      public static void queueAction(Action action)
    • getState

      public static int getState()
      Gets the current game state.

      The returned game state can be compared against the predefined STATE_ constants in the Game class to determine the current phase of the game. For example, STATE_IN_GAME represents the state when the player is actively in-game.

      Returns:
      the current game state as an integer
      See Also:
    • isWorldHopping

      public static boolean isWorldHopping()
    • isLoggedIn

      public static boolean isLoggedIn()
      Checks if the player is logged in.
      Returns:
      true if the player is logged in; false otherwise
    • isOnCredentialsScreen

      public static boolean isOnCredentialsScreen()
    • isLoadingRegion

      public static boolean isLoadingRegion()
    • getEngineCycle

      public static int getEngineCycle()
    • getCanvas

      public static Canvas getCanvas()
    • getEventDispatcher

      public static org.rspeer.event.EventDispatcher getEventDispatcher()
    • call

      public static <T> T call(Callable<T> callable, T fallback)
      Executes a callable task on the game thread.
      Type Parameters:
      T - the return type of the task
      Parameters:
      callable - the task to execute
      Returns:
      the result of the task, or null if an error occurs
    • call

      public static <T> T call(Callable<T> callable)
    • callAsync

      public static <T> CompletableFuture<T> callAsync(Function<jag.oldscape.RSClient, T> function)
      Executes a function asynchronously on the game thread.
      Type Parameters:
      T - the return type of the function
      Parameters:
      function - the function to execute
      Returns:
      a CompletableFuture representing the result
    • call

      public static void call(Runnable runnable)
      Executes a task on the game thread.
      Parameters:
      runnable - the task to execute
    • getProxy

      public static Proxy getProxy()
    • getProxyCredentials

      public static org.rspeer.commons.Pair<String,String> getProxyCredentials()
    • isClientThread

      public static boolean isClientThread()
    • hasClientAccess

      public static boolean hasClientAccess()
    • isMainLoopRunning

      public static boolean isMainLoopRunning()
    • lockClientAccess

      public static GameLogic.ClientAccess lockClientAccess()
    • tryLockClientAccess

      public static GameLogic.ClientAccess tryLockClientAccess()
    • checkClientThread

      public static void checkClientThread(String operation)
    • awaitMainLoopIdle

      public static void awaitMainLoopIdle()
    • withIdleAccess

      public static void withIdleAccess(Runnable runnable)
    • tryWithIdleAccess

      public static boolean tryWithIdleAccess(Runnable runnable)
    • withIdleAccess

      public static <T> T withIdleAccess(Callable<T> callable, T fallback)
    • setProxy

      public static void setProxy(Proxy proxy, String username, String password)
    • isVerboseMenuActions

      public static boolean isVerboseMenuActions()
    • setVerboseMenuActions

      public static void setVerboseMenuActions(boolean verboseMenuActions)
    • isSceneRenderingDisabled

      public static boolean isSceneRenderingDisabled()
    • setSceneRenderingDisabled

      public static void setSceneRenderingDisabled(boolean sceneRenderingDisabled)
    • getUsernameOrCharacterId

      public static String getUsernameOrCharacterId()