Package com.kraken.api
Class Context
- java.lang.Object
-
- com.kraken.api.Context
-
public class Context extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Context(net.runelite.api.Client client, net.runelite.client.callback.ClientThread clientThread, VirtualMouse mouse, net.runelite.client.eventbus.EventBus eventBus, com.google.inject.Injector injector, InteractionManager interactionManager, TileService tileService, BankService bankService, net.runelite.client.game.ItemManager itemManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BankQuerybank()Creates a new query builder for the Bank interface.BankInventoryQuerybankInventory()Creates a new query builder for a Bank Inventory.EquipmentQueryequipment()Creates a new query builder for the equipment interface.GameObjectQuerygameObjects()Creates a new query builder for game objects.<T> TgetService(java.lang.Class<T> serviceClass)Retrieves an instance of a specified service class.intgetVarbitValue(int varbit)Returns a varbit value from the RuneLite client.intgetVarpValue(int varp)Returns a var player value from the RuneLite client.net.runelite.api.widgets.WidgetgetWidget(int widgetId)Retrieves a Widget from the RuneLite client.GroundObjectQuerygroundItems()Creates a new query builder for Ground Items.voidinitializePackets()Initializes packet queueing functionality by either loading the client packet sending method from the cached json file or running an analysis on the RuneLite injected client to determine the packet sending method.InventoryQueryinventory()Creates a new query builder for the standard Backpack Inventory.NpcQuerynpcs()Creates a new query builder for NPCs.PlayerQueryplayers()Creates a new query builder for Players.voidrunOnClientThread(java.lang.Runnable method)Runs a method on the client thread without returning a result.<T> TrunOnClientThread(java.util.concurrent.Callable<T> method)Run a method on the client thread, returning the result directly.<T> java.util.Optional<T>runOnClientThreadOptional(java.util.concurrent.Callable<T> method)Run a method on the client thread, returning an optional of the result.WidgetQuerywidgets()Creates a new query builder for Widgets.WorldQueryworlds()Creates a new query builder for Worlds.
-
-
-
Constructor Detail
-
Context
@Inject public Context(net.runelite.api.Client client, net.runelite.client.callback.ClientThread clientThread, VirtualMouse mouse, net.runelite.client.eventbus.EventBus eventBus, com.google.inject.Injector injector, InteractionManager interactionManager, TileService tileService, BankService bankService, net.runelite.client.game.ItemManager itemManager)
-
-
Method Detail
-
initializePackets
public void initializePackets()
Initializes packet queueing functionality by either loading the client packet sending method from the cached json file or running an analysis on the RuneLite injected client to determine the packet sending method.This is required to be called before packets can actually be sent i.e. its necessary to know the packet method in the client before calling it with reflection.
-
getVarbitValue
public int getVarbitValue(int varbit)
Returns a varbit value from the RuneLite client. This method is thread-safe and runs on the client thread to retrieve the value.- Parameters:
varbit- The varbit value to retrieve.- Returns:
- The varbit value (either 0 for false/unset or 1 for true/set).
-
getVarpValue
public int getVarpValue(int varp)
Returns a var player value from the RuneLite client. This method is thread-safe and runs on the client thread to retrieve the value.- Parameters:
varp- The varp value to retrieve.- Returns:
- The varp value (either 0 for false/unset or 1 for true/set).
-
getWidget
public net.runelite.api.widgets.Widget getWidget(int widgetId)
Retrieves a Widget from the RuneLite client. This method is thread-safe and will run on the client thread to retrieve the Widget.- Parameters:
widgetId- int The widget id- Returns:
- Widget
-
runOnClientThread
public <T> T runOnClientThread(java.util.concurrent.Callable<T> method)
Run a method on the client thread, returning the result directly.- Type Parameters:
T- The type of the method's return value- Parameters:
method- The method to call- Returns:
- The result from the called method
-
runOnClientThread
public void runOnClientThread(java.lang.Runnable method)
Runs a method on the client thread without returning a result.- Parameters:
method- Runnable method to execute
-
runOnClientThreadOptional
public <T> java.util.Optional<T> runOnClientThreadOptional(java.util.concurrent.Callable<T> method)
Run a method on the client thread, returning an optional of the result.- Type Parameters:
T- The type of the method's return value- Parameters:
method- The method to call- Returns:
- The result from the called method
-
getService
public <T> T getService(java.lang.Class<T> serviceClass)
Retrieves an instance of a specified service class.- Type Parameters:
T- The type of the service.- Parameters:
serviceClass- The class of the service to retrieve.- Returns:
- The instance of the service.
-
npcs
public NpcQuery npcs()
Creates a new query builder for NPCs. Usage: ctx.npcs().withName("Goblin").first().interact("Attack");- Returns:
- NpcQuery object used to chain together predicates to select specific NPC's within the scene.
-
players
public PlayerQuery players()
Creates a new query builder for Players. This will also include the local player as well which can be grabbed with.local(). Usage: ctx.players().withName("Zezima").first().interact("Follow"); ctx.players().local().getName();- Returns:
- PlayerQuery object used to chain together predicates to select specific Players's within the scene.
-
inventory
public InventoryQuery inventory()
Creates a new query builder for the standard Backpack Inventory. This is only for finding items in a players inventory and should not be used when the Bank is open to deposit items. Instead, useBankInventoryQueryfor depositing items. Usage: ctx.inventory().withId(1234).count();- Returns:
- InventoryQuery object used to chain together predicates to select specific items or groups of items within the players inventory.
-
bankInventory
public BankInventoryQuery bankInventory()
Creates a new query builder for a Bank Inventory. This should only be used when the bank is open in order to deposit items from the players inventory into the bank. A different parent widget is used for the players inventory while the bank is open compared to the normal players inventory. For querying the players inventory to eat food, interact with objects, or perform general actions without a bank use:InventoryQuery. Usage: ctx.bankInventory().withId(1234).count();- Returns:
- BankInventoryQuery object used to chain together predicates to select specific items or groups of items within the players inventory while the bank interface is open.
-
bank
public BankQuery bank()
Creates a new query builder for the Bank interface. Usage: ctx.bank().withId(1234).interact("Withdraw-X");- Returns:
- BankQuery object used to chain together predicates to select specific items or groups of items within the players bank.
-
equipment
public EquipmentQuery equipment()
Creates a new query builder for the equipment interface. Usage: ctx.equipment().inSlot(EquipmentInventorySlot.HEAD).interact("Remove"); ctx.equipment().withId(1234).interact("Wield");- Returns:
- EquipmentQuery object used to chain together predicates to select specific items or groups of items within the players equipment or inventory interface. Only items with the action "wield" or "wear" will be interactable using this query from the inventory.
-
gameObjects
public GameObjectQuery gameObjects()
Creates a new query builder for game objects. Game objects are objects in the game world like: Trees, ore, or fishing spots which exist on tiles, can be interacted with, but cannot be picked up by the player. Usage: ctx.gameObjects().withName("Oak Tree").nearest().interact("Chop");- Returns:
- GameObjectQuery used to chain together predicates to select specific game objects within the scene.
-
groundItems
public GroundObjectQuery groundItems()
Creates a new query builder for Ground Items. GroundItems are items that exist on a tile that the player can pick up and store in their inventory. Examples include: bones dropped from an NPC or loot dropped by another player on a tile. Usage: ctx.groundObjects().withName("Twisted Bow").nearest().interact("Take");- Returns:
- GroundObjectQuery used to chain together predicates to select specific ground items within the scene.
-
widgets
public WidgetQuery widgets()
Creates a new query builder for Widgets. Usage: ctx.widgets().withText("Log Out").interact();- Returns:
- WidgetQuery used to chain together predicates to select specific widgets within the client.
-
worlds
public WorldQuery worlds()
Creates a new query builder for Worlds. A WorldQuery provides functionality for filtering and selecting specific game worlds based on various criteria, such as population, world type, or location.Worlds are the game servers that players can connect to. Each world may have unique properties, such as member status, high population, or special game rules.
- Returns:
- @WorldQuery object used to chain together predicates to select specific game worlds.
-
-