GameAPI
Check the state of the game before your plugin acts.
ClassRLPlugins API
public class GameAPICall these at the top of an event handler and return early while the game is not ready for input.
Example
@Subscribe
public void onGameTick(GameTick tick) {
if (!GameAPI.isLoggedIn() || GameAPI.isInCutscene() || GameAPI.isScreenFading()) {
return;
}
// The game is ready for input this tick.
}Members
Static methods
- intgetMembershipDays()
Gets the number of membership days remaining.
- intgetPlaytimeInMinutes()
Note: The character summary subtab must be opened for this to update otherwise it returns a cached value.
- List<String>getRecentGameMessages()
Snapshot of retained game-message text in the client's native history iteration order.
- intgetWildyLevel()
Gets the current wilderness level, or 0 if not in the wilderness.
- voidinvokeMenuAction(int, int, int, int, int)
Dispatches a supported server action through typed packets, without native doAction.
- voidinvokeMenuAction(int, int, int, int, int, int)
Dispatches a supported server action through typed packets in the specified world view.
- booleanisInCutscene()
Whether a cutscene is playing.
- booleanisInInstance()
Whether you are in an instanced area.
- booleanisLoggedIn()
Whether you are logged in.
- booleanisOnLoginScreen()
Whether the login screen is showing.
- booleanisScreenFading()
Whether the game screen is fading in or out.
- voidlogout()
Logs out of the game.
getMembershipDays()static
public static int getMembershipDays()Gets the number of membership days remaining.
Returns
The number of membership days remaining.
getPlaytimeInMinutes()static
public static int getPlaytimeInMinutes()Note: The character summary subtab must be opened for this to update otherwise it returns a cached value.
For accounts that have never opened it, the value will be -1. If the tab is already open, it won't update. You have to open another subtab and then reopen it.
Returns
The accounts playtime in minutes.
getRecentGameMessages()static
public static List<String> getRecentGameMessages()Snapshot of retained game-message text in the client's native history iteration order.
getWildyLevel()static
public static int getWildyLevel()Gets the current wilderness level, or 0 if not in the wilderness.
Returns
The wilderness level.
invokeMenuAction(int, int, int, int, int)static
public static void invokeMenuAction(int identifier, int opcode, int param0, int param1, int itemId)Dispatches a supported server action through typed packets, without native doAction.
Client-only selection/examine actions require their dedicated UI APIs.
Parameters
identifier- Identifier.
opcode- Opcode.
param0- Param0.
param1- Param1.
itemId- ItemId.
invokeMenuAction(int, int, int, int, int, int)static
public static void invokeMenuAction(int identifier, int opcode, int param0, int param1, int itemId, int worldViewId)Dispatches a supported server action through typed packets in the specified world view.
There is no native doAction fallback for unsupported operations.
Parameters
identifier- Identifier.
opcode- Opcode.
param0- Param0.
param1- Param1.
itemId- ItemId.
worldViewId- World view id.
isInCutscene()static
public static boolean isInCutscene()Whether a cutscene is playing.
Returns
true while a cutscene plays.
isInInstance()static
public static boolean isInInstance()Whether you are in an instanced area.
Instances are private copies of an area, used by many boss rooms and raids.
Returns
true in an instance. false when the game has no world loaded.
isLoggedIn()static
public static boolean isLoggedIn()Whether you are logged in.
Returns
true while you are logged in to the game.
isOnLoginScreen()static
public static boolean isOnLoginScreen()Whether the login screen is showing.
Returns
true on the login screen.
isScreenFading()static
public static boolean isScreenFading()Whether the game screen is fading in or out.
Returns
true while the screen fades.
- Wait until this is
falsebefore you click.
logout()static
public static void logout()Logs out of the game.
Also allowed
Every class has these, as in plain Java.
equals, toString