Package org.rspeer.game
Class Game
- java.lang.Object
-
- org.rspeer.game.Game
-
public class Game extends Object
Provides general game state operations
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGame.ScriptExecutor
-
Field Summary
Fields Modifier and Type Field Description static intSTATE_AUTHENTICATOR_SCREENRepresents the state of the authenticator screen.static intSTATE_CONNECTION_LOSTRepresents the state when the connection is lost.static intSTATE_CREDENTIALS_SCREENRepresents the state of the credentials screen.static intSTATE_HOPPING_WORLDRepresents the state during world hopping.static intSTATE_IN_GAMERepresents the state when the player is in-game.static intSTATE_LOADING_GAMERepresents the game state during loading.static intSTATE_LOADING_REGIONRepresents the game state while loading a region.static intSTATE_LOGGING_INRepresents the game state during the login process.
-
Constructor Summary
Constructors Constructor Description Game()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidaddMouseListener(BotMouseListener listener)Deprecated.static voidcall(Runnable runnable)Executes a task on the game thread.static <T> Tcall(Callable<T> callable)Executes a callable task on the game thread.static <T> CompletableFuture<T>callAsync(Function<RSClient,T> function)Executes a function asynchronously on the game thread.static AccountTypegetAccountType()static Predicate<MenuActionEvent>getActionFilter()static CanvasgetCanvas()static RSClientgetClient()static RSClientPreferencesgetClientPreferences()static intgetEngineCycle()static EventDispatchergetEventDispatcher()static EventMediatorgetEventMediator()static List<BotMouseListener>getMouseListeners()Deprecated.static ProxygetProxy()static Pair<String,String>getProxyCredentials()static intgetRemainingMembershipDays()static intgetRevision()static intgetServerTick()static intgetState()Gets the current game state.static intgetTick()Deprecated.static intgetTickCount()static booleanisLoadingRegion()static booleanisLoggedIn()Checks if the player is logged in.static booleanisMembershipPresent()static booleanisOnCredentialsScreen()static booleanisVerboseMenuActions()static booleanlogout()static booleanlogout(boolean direct)static voidqueueAction(Action action)static voidqueueAction(MenuAction action)static voidremoveMouseListener(BotMouseListener listener)Deprecated.static voidsetActionFilter(Predicate<MenuActionEvent> actionFilter)static voidsetClient(RSClient client)static voidsetFps(int fps)static voidsetProxy(Proxy proxy)static voidsetProxyCredentials(Pair<String,String> proxyCredentials)static voidsetTickCount(int tickCount)static voidsetVerboseMenuActions(boolean verboseMenuActions)
-
-
-
Field Detail
-
STATE_LOADING_GAME
public static final int STATE_LOADING_GAME
Represents the game state during loading.- See Also:
- Constant Field Values
-
STATE_CREDENTIALS_SCREEN
public static final int STATE_CREDENTIALS_SCREEN
Represents the state of the credentials screen.- See Also:
- Constant Field Values
-
STATE_AUTHENTICATOR_SCREEN
public static final int STATE_AUTHENTICATOR_SCREEN
Represents the state of the authenticator screen.- See Also:
- Constant Field Values
-
STATE_LOGGING_IN
public static final int STATE_LOGGING_IN
Represents the game state during the login process.- See Also:
- Constant Field Values
-
STATE_LOADING_REGION
public static final int STATE_LOADING_REGION
Represents the game state while loading a region.- See Also:
- Constant Field Values
-
STATE_IN_GAME
public static final int STATE_IN_GAME
Represents the state when the player is in-game.- See Also:
- Constant Field Values
-
STATE_CONNECTION_LOST
public static final int STATE_CONNECTION_LOST
Represents the state when the connection is lost.- See Also:
- Constant Field Values
-
STATE_HOPPING_WORLD
public static final int STATE_HOPPING_WORLD
Represents the state during world hopping.- See Also:
- Constant Field Values
-
-
Method Detail
-
getClient
public static RSClient getClient()
-
setClient
public static void setClient(RSClient client)
-
getRevision
public static int getRevision()
-
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)
-
getRemainingMembershipDays
public static int getRemainingMembershipDays()
-
isMembershipPresent
public static boolean isMembershipPresent()
-
logout
public static boolean logout()
-
logout
public static boolean logout(boolean direct)
- Parameters:
direct-trueindicates to instantly log out by setting the clients main state.falsemeans to use the logout button in game- Returns:
trueif an attempt was made to log out
-
getAccountType
public static AccountType getAccountType()
-
addMouseListener
@Deprecated public static void addMouseListener(BotMouseListener listener)
Deprecated.- See Also:
GameCanvas
-
removeMouseListener
@Deprecated public static void removeMouseListener(BotMouseListener listener)
Deprecated.- See Also:
GameCanvas
-
getMouseListeners
@Deprecated public static List<BotMouseListener> getMouseListeners()
Deprecated.- See Also:
GameCanvas
-
queueAction
public static void queueAction(MenuAction action)
-
queueAction
public static void queueAction(Action action)
-
getClientPreferences
public static RSClientPreferences getClientPreferences()
-
getState
public static int getState()
Gets the current game state.The returned game state can be compared against the predefined
STATE_constants in theGameclass to determine the current phase of the game. For example,STATE_IN_GAMErepresents the state when the player is actively in-game.- Returns:
- the current game state as an integer
- See Also:
STATE_LOADING_GAME,STATE_CREDENTIALS_SCREEN,STATE_AUTHENTICATOR_SCREEN,STATE_LOGGING_IN,STATE_LOADING_REGION,STATE_IN_GAME,STATE_CONNECTION_LOST,STATE_HOPPING_WORLD
-
isLoggedIn
public static boolean isLoggedIn()
Checks if the player is logged in.- Returns:
trueif the player is logged in;falseotherwise
-
isOnCredentialsScreen
public static boolean isOnCredentialsScreen()
-
isLoadingRegion
public static boolean isLoadingRegion()
-
getEngineCycle
public static int getEngineCycle()
-
getCanvas
public static Canvas getCanvas()
-
getEventMediator
public static EventMediator getEventMediator()
-
getEventDispatcher
public static EventDispatcher getEventDispatcher()
-
call
public static <T> T call(Callable<T> callable)
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
nullif an error occurs
-
callAsync
public static <T> CompletableFuture<T> callAsync(Function<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
CompletableFuturerepresenting 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()
-
setProxy
public static void setProxy(Proxy proxy)
-
getActionFilter
public static Predicate<MenuActionEvent> getActionFilter()
-
setActionFilter
public static void setActionFilter(Predicate<MenuActionEvent> actionFilter)
-
isVerboseMenuActions
public static boolean isVerboseMenuActions()
-
setVerboseMenuActions
public static void setVerboseMenuActions(boolean verboseMenuActions)
-
-