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 class
Game.ScriptExecutor
-
Field Summary
Fields Modifier and Type Field Description static int
STATE_AUTHENTICATOR_SCREEN
Represents the state of the authenticator screen.static int
STATE_CONNECTION_LOST
Represents the state when the connection is lost.static int
STATE_CREDENTIALS_SCREEN
Represents the state of the credentials screen.static int
STATE_HOPPING_WORLD
Represents the state during world hopping.static int
STATE_IN_GAME
Represents the state when the player is in-game.static int
STATE_LOADING_GAME
Represents the game state during loading.static int
STATE_LOADING_REGION
Represents the game state while loading a region.static int
STATE_LOGGING_IN
Represents 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 void
addMouseListener(BotMouseListener listener)
Deprecated.static void
call(Runnable runnable)
Executes a task on the game thread.static <T> T
call(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 AccountType
getAccountType()
static Predicate<MenuActionEvent>
getActionFilter()
static Canvas
getCanvas()
static RSClient
getClient()
static RSClientPreferences
getClientPreferences()
static int
getEngineCycle()
static EventDispatcher
getEventDispatcher()
static EventMediator
getEventMediator()
static List<BotMouseListener>
getMouseListeners()
Deprecated.static Proxy
getProxy()
static Pair<String,String>
getProxyCredentials()
static int
getRemainingMembershipDays()
static int
getRevision()
static int
getState()
Gets the current game state.static int
getTick()
static boolean
isLoadingRegion()
static boolean
isLoggedIn()
Checks if the player is logged in.static boolean
isMembershipPresent()
static boolean
isOnCredentialsScreen()
static boolean
isVerboseMenuActions()
static boolean
logout()
static boolean
logout(boolean direct)
static void
queueAction(Action action)
static void
queueAction(MenuAction action)
static void
removeMouseListener(BotMouseListener listener)
Deprecated.static void
setActionFilter(Predicate<MenuActionEvent> actionFilter)
static void
setClient(RSClient client)
static void
setFps(int fps)
static void
setProxy(Proxy proxy)
static void
setProxyCredentials(Pair<String,String> proxyCredentials)
static void
setVerboseMenuActions(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
public static int getTick()
-
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:
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 theGame
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:
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:
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()
-
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
null
if 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
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()
-
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)
-
-