BankAPI
Open the bank, see what is in it, withdraw, deposit and close it.
ClassRLPlugins API
public class BankAPIThe request methods do not wait. Each call clicks at most once and returns at once, so call them from a GameTick handler and read the result on a later tick, for example with isOpen() or InventoryAPI.count(int...).
Open the bank at least once after you log in before you read what is in it. Item names must match exactly, including capital letters, as in "Lobster".
Example
private static final int LOBSTER = 379;
private int waitTicks;
@Subscribe
public void onGameTick(GameTick tick) {
if (!GameAPI.isLoggedIn()) {
return;
}
if (waitTicks > 0) {
waitTicks--;
return;
}
if (!BankAPI.isOpen()) {
BankAPI.requestOpen();
waitTicks = 1;
} else if (!InventoryAPI.contains(LOBSTER) && BankAPI.contains(LOBSTER)) {
if (BankAPI.requestWithdraw(LOBSTER, 10, false)) {
waitTicks = 2; // give the inventory time to update
}
}
}Members
Static methods
- voidbankUse(String)
Presses Use on an item while the bank is open.
- voidbankUse(int)
Presses Use on an item while the bank is open.
- voidcancelQuantityRequest()
Cancel only this owner's pending numeric request during a caller's lifecycle reset.
- voidclose()
Closes the bank.
- booleancontains(String)
Whether the bank holds an item with this name.
- booleancontains(int...)
Whether the bank holds any of these items.
- intcount(String)
How many of an item the bank holds.
- intcount(int)
How many of an item the bank holds.
- voiddeposit(String, int)
Deposits the specified amount of the item with the given name into the bank.
- voiddeposit(int, int)
Deposits the specified amount of the item with the given id into the bank.
- voiddepositAction(int, int, int)
Invokes the deposit action on the inventory item.
- voiddepositAll()
Deposits all items from the inventory into the bank.
- voiddepositAllContainers()
Presses the bank button that empties the containers you carry.
- voiddepositEquipment()
Deposits all items from the equipment into the bank.
- voiddragItem(ItemEx, int)
Drags a bank item to another slot.
- voiddragItem(int, int)
Drags a bank item to another slot.
- voiddragItem(int, int, int)
Drags a bank item to another slot.
- voiddragItemToTab(ItemEx, int)
Drags a bank item to a bank tab.
- voiddragItemToTab(int, int)
Drags a bank item to a bank tab.
- voiddragItemToTab(int, int, int)
Drags a bank item to a bank tab.
- booleanequipInventoryItem(ItemEx)
Equip a carried item through the bank side inventory while the bank remains open.
- intgetSlot(String)
Gets the slot of the item with the specified name in the bank.
- intgetSlot(int)
Gets the slot of the item with the specified id in the bank.
- intgetX()
The amount the bank's X button is set to.
- booleaninteractInventoryItem(ItemEx, String)
Use an available carried-item action, such as Drink or Fill, while the bank stays open.
- booleanisMainTabOpen()
Whether the main bank tab is open.
- booleanisOpen()
Whether the bank window is open.
- booleanisPinOpen()
Whether the bank PIN screen is showing.
- booleanisWithdrawNote()
Whether the bank is set to withdraw as notes.
- voidopenMainTab()
Opens the main bank tab.
- booleanrequestDeposit(int, int)
Deposits an item from your inventory.
- booleanrequestOpen()
Walks to the nearest bank and opens it, one step per call.
- booleanrequestWithdraw(int, int, boolean)
Withdraws an item from the bank.
- InventoryQuerysearch()
Starts a search over the items in the bank.
- voidsetWithdrawMode(boolean)
Sets the withdraw mode to either noted or unnoted.
- voidsetX(int)
Sets the withdraw amount to the specified amount.
- voiduse(String)
Uses the item with the specified name from the inventory.
- voiduse(int)
Uses the item with the specified id from the inventory.
- voiduseGuessNextSlot(int)
Attempts to guess the slot an item will be withdrawn into (for use in programatically 1-ticking interactions with withdrawn items) and "uses" the item.
- booleanwithdraw(InventoryLoadout)
Makes your inventory match a loadout. It deposits what does not belong and withdraws what is missing.
- booleanwithdraw(InventoryLoadout, int)
Makes your inventory match a loadout, with at most this many clicks per tick.
- voidwithdraw(ItemEx, int, boolean)
Withdraws an item, as a note or as the item itself.
- voidwithdraw(String, int, boolean)
Withdraws the specified amount of the item with the given name from the bank.
- voidwithdraw(int, int, boolean)
Withdraws the specified amount of the item with the given id from the bank.
- voidwithdrawAction(int, int, int)
Invokes the withdraw action on the bank item.
bankUse(String)static
public static void bankUse(String itemName)Presses Use on an item while the bank is open.
Parameters
itemName- Item name.
bankUse(int)static
public static void bankUse(int itemId)Presses Use on an item while the bank is open.
Parameters
itemId- Item id.
cancelQuantityRequest()static
public static void cancelQuantityRequest()Cancel only this owner's pending numeric request during a caller's lifecycle reset.
close()static
public static void close()Closes the bank.
Does nothing when the bank is not open.
contains(String)static
public static boolean contains(String itemName)Whether the bank holds an item with this name.
Parameters
itemName- The exact item name, including capital letters.
Returns
true if at least one is in the bank.
contains(int...)static
public static boolean contains(int... itemIds)Whether the bank holds any of these items.
Parameters
itemIds- One or more item IDs.
Returns
true if at least one of the IDs is in the bank.
- One match is enough here.
InventoryAPI.contains(int...)needs all of them.
count(String)static
public static int count(String itemName)How many of an item the bank holds.
Parameters
itemName- The exact item name, including capital letters.
Returns
The total quantity, or 0.
count(int)static
public static int count(int itemId)How many of an item the bank holds.
Parameters
itemId- The item ID.
Returns
The total quantity, or 0.
deposit(String, int)static
public static void deposit(String name, int amount)Deposits the specified amount of the item with the given name into the bank.
Parameters
name- The name of the item to deposit.
amount- The amount to deposit. Use -1 for "all" option.
- Can wait for the game. Call it only from
VitaPlugin.loop(); in a@Subscribemethod it freezes the game.
deposit(int, int)static
public static void deposit(int id, int amount)Deposits the specified amount of the item with the given id into the bank.
Parameters
id- The id of the item to deposit.
amount- The amount to deposit. Use -1 for "all" option.
- Can wait for the game. Call it only from
VitaPlugin.loop(); in a@Subscribemethod it freezes the game.
depositAction(int, int, int)static
public static void depositAction(int id, int amount, int slot)Invokes the deposit action on the inventory item.
Parameters
id- The id of the item to deposit.
amount- The amount to deposit.
slot- The slot of the item in the inventory.
- Can wait for the game. Call it only from
VitaPlugin.loop(); in a@Subscribemethod it freezes the game.
depositAll()static
public static void depositAll()Deposits all items from the inventory into the bank.
depositAllContainers()static
public static void depositAllContainers()Presses the bank button that empties the containers you carry.
depositEquipment()static
public static void depositEquipment()Deposits all items from the equipment into the bank.
dragItem(ItemEx, int)static
public static void dragItem(ItemEx item, int toSlot)Drags a bank item to another slot.
Parameters
item- Item.
toSlot- To slot.
dragItem(int, int)static
public static void dragItem(int id, int toSlot)Drags a bank item to another slot.
Parameters
id- Id.
toSlot- To slot.
dragItem(int, int, int)static
public static void dragItem(int itemId, int fromSlot, int toSlot)Drags a bank item to another slot.
Parameters
itemId- Item id.
fromSlot- From slot.
toSlot- To slot.
dragItemToTab(ItemEx, int)static
public static void dragItemToTab(ItemEx item, int toTab)Drags a bank item to a bank tab.
Parameters
item- Item.
toTab- To tab.
dragItemToTab(int, int)static
public static void dragItemToTab(int id, int toTab)Drags a bank item to a bank tab.
Parameters
id- Id.
toTab- To tab.
dragItemToTab(int, int, int)static
public static void dragItemToTab(int itemId, int fromSlot, int toTab)Drags a bank item to a bank tab.
Parameters
itemId- Item id.
fromSlot- From slot.
toTab- To tab.
equipInventoryItem(ItemEx)static
public static boolean equipInventoryItem(ItemEx item)Equip a carried item through the bank side inventory while the bank remains open.
Parameters
item- Item.
getSlot(String)static
public static int getSlot(String itemName)Gets the slot of the item with the specified name in the bank.
Parameters
itemName- The name of the item to get the slot for.
Returns
The slot of the item in the bank, or -1 if the item is not found.
getSlot(int)static
public static int getSlot(int itemId)Gets the slot of the item with the specified id in the bank.
Parameters
itemId- The id of the item to get the slot for.
Returns
The slot of the item in the bank, or -1 if the item is not found.
getX()static
public static int getX()The amount the bank's X button is set to.
interactInventoryItem(ItemEx, String)static
public static boolean interactInventoryItem(ItemEx item, String action)Use an available carried-item action, such as Drink or Fill, while the bank stays open.
Parameters
item- Item.
action- Action.
isMainTabOpen()static
public static boolean isMainTabOpen()Whether the main bank tab is open.
isOpen()static
public static boolean isOpen()Whether the bank window is open.
Returns
true while the bank shows. false while only the PIN screen shows.
isPinOpen()static
public static boolean isPinOpen()Whether the bank PIN screen is showing.
Returns
true while the PIN screen is open.
- The SDK cannot type a PIN. Wait until the player has entered it.
isWithdrawNote()static
public static boolean isWithdrawNote()Whether the bank is set to withdraw as notes.
openMainTab()static
public static void openMainTab()Opens the main bank tab.
requestDeposit(int, int)static
public static boolean requestDeposit(int id, int amount)Deposits an item from your inventory.
Clicks once and returns. An amount that is not on the item's menu uses Deposit-X, which takes two calls: the first opens the amount prompt and a call on a later tick types the amount.
Parameters
id- The item ID in your inventory.
amount- How many to deposit.
-1deposits all of them.
Returns
true when the deposit was sent. false when the bank is closed, the item is not in your inventory, the amount is 0 or below -1, or the amount prompt needs another call.
BankAPI.requestDeposit(379, -1); // deposit every lobsterrequestOpen()static
public static boolean requestOpen()Walks to the nearest bank and opens it, one step per call.
Picks the nearest banker, bank booth or bank chest you can reach. If it is more than 8 tiles away, it walks toward it; otherwise it clicks Bank, Use or Open. When the bank is already open, it switches to the main tab.
Returns
true while it is working or done: it walked or clicked, you are still walking, the PIN screen shows, or the bank is open. false when you are not logged in or there is no bank nearby.
- Call it again on later ticks until
isOpen()istrue.
requestWithdraw(int, int, boolean)static
public static boolean requestWithdraw(int id, int amount, boolean noted)Withdraws an item from the bank.
Clicks once and returns. If the bank's note setting does not match noted, this call switches it and returns false: call again on a later tick.
An amount that is not on the item's menu uses Withdraw-X, which takes two calls: the first opens the amount prompt and a call on a later tick types the amount. Placeholders are ignored.
Parameters
id- The item ID. The ID of its noted form also works.
amount- How many to withdraw.
-1withdraws all of them. notedtrueto withdraw as notes.
Returns
true when the withdrawal was sent. false when the bank is closed, the item is not in the bank, the amount is 0 or below -1, or another call is needed.
- Check your inventory on a later tick to confirm the items arrived.
search()static
public static InventoryQuery search()Starts a search over the items in the bank.
setWithdrawMode(boolean)static
public static void setWithdrawMode(boolean noted)Sets the withdraw mode to either noted or unnoted.
Parameters
noted- True for noted, false for unnoted.
setX(int)static
public static void setX(int amount)Sets the withdraw amount to the specified amount.
Parameters
amount- The amount to set the withdraw amount to.
- Can wait for the game. Call it only from
VitaPlugin.loop(); in a@Subscribemethod it freezes the game.
use(String)static
public static void use(String itemName)Uses the item with the specified name from the inventory.
Parameters
itemName- The name of the item to use.
use(int)static
public static void use(int itemId)Uses the item with the specified id from the inventory.
Parameters
itemId- The id of the item to use.
useGuessNextSlot(int)static
public static void useGuessNextSlot(int itemId)Attempts to guess the slot an item will be withdrawn into (for use in programatically 1-ticking interactions with withdrawn items) and "uses" the item.
Not guarenteed to be 100% accurate.
Parameters
itemId- The item id.
withdraw(InventoryLoadout)static
public static boolean withdraw(InventoryLoadout loadout)Makes your inventory match a loadout. It deposits what does not belong and withdraws what is missing.
Parameters
loadout- Loadout.
- Can wait for the game. Call it only from
VitaPlugin.loop(); in a@Subscribemethod it freezes the game.
withdraw(InventoryLoadout, int)static
public static boolean withdraw(InventoryLoadout loadout, int maxActionsPerTick)Makes your inventory match a loadout, with at most this many clicks per tick.
Parameters
loadout- Loadout.
maxActionsPerTick- Max actions per tick.
- Can wait for the game. Call it only from
VitaPlugin.loop(); in a@Subscribemethod it freezes the game.
withdraw(ItemEx, int, boolean)static
public static void withdraw(ItemEx item, int amount, boolean noted)Withdraws an item, as a note or as the item itself.
Parameters
item- Item.
amount- Amount.
noted- Noted.
- Can wait for the game. Call it only from
VitaPlugin.loop(); in a@Subscribemethod it freezes the game.
withdraw(String, int, boolean)static
public static void withdraw(String name, int amount, boolean noted)Withdraws the specified amount of the item with the given name from the bank.
Parameters
name- The name of the item to withdraw.
amount- The amount to withdraw. Use -1 for "all" option.
noted- True to withdraw as noted, false to withdraw as unnoted.
- Can wait for the game. Call it only from
VitaPlugin.loop(); in a@Subscribemethod it freezes the game.
withdraw(int, int, boolean)static
public static void withdraw(int id, int amount, boolean noted)Withdraws the specified amount of the item with the given id from the bank.
Parameters
id- The id of the item to withdraw.
amount- The amount to withdraw. Use -1 for "all" option.
noted- True to withdraw as noted, false to withdraw as unnoted.
- Can wait for the game. Call it only from
VitaPlugin.loop(); in a@Subscribemethod it freezes the game.
withdrawAction(int, int, int)static
public static void withdrawAction(int id, int amount, int slot)Invokes the withdraw action on the bank item.
Parameters
id- The id of the item to withdraw.
amount- The amount to withdraw.
slot- The slot of the item in the bank.
- Can wait for the game. Call it only from
VitaPlugin.loop(); in a@Subscribemethod it freezes the game.
Also allowed
Every class has these, as in plain Java.
equals, toString