Class Bank
Reads that touch live client state marshal via GameThread.ensure(java.util.function.Supplier<T>, T) (same pattern as
GameObjects.query()) so script-thread callers stay safe.
Session buttons (deposit inventory / deposit worn / close) are BankSession, which clicks each
server's own buttons. Do not gate close on isOpen() — that read lies on Impact.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidLast-resort banker interaction when no bank object is found (server-specific; uses injected adapter).booleanclose()Closes the bank interface.booleanDeprecated.close()with an explicit outcome.booleancontains(int... ids) booleanintcount(int id) intstatic intcountAll(int id) Static count through the process-wide adapter; preferctx.bank.count(id).static intStatic count through the process-wide adapter; preferctx.bank.count(name).booleandeposit1(int itemId) Deposit 1 of the given item id from inventory.booleandepositAll(int itemId) Deposit all stacks of the given item id from inventory into the bank.booleandepositAll(String name) Deposit all stacks of the first inventory slot matching the given display name.depositAllOutcome(int itemId) depositAll(int)with an explicit outcome.depositAllOutcome(String name) depositAll(String)with an explicit outcome.booleanDeposits all worn equipment using the "Deposit worn items" bank button.depositEquipment()with an explicit outcome.booleanDeposits all items currently in inventory using the "Deposit inventory" bank button.depositInventory()with an explicit outcome.booleandepositItem(int slot, int itemId) Deposits one inventory stack fromslot(same menu shape as legacy bank deposit-by-slot).static PrivItemStatic lookup through the process-wide adapter; preferctx.bank.get(pred).Same asget(Predicate).booleanTrue when the bank holds at least one item whose display name matchesname(case-insensitive).booleanDeprecated.useisOpen()(orobservedOpen()to tell "closed" from "cannot tell")booleanisEmpty()booleanisOpen()Whether the bank reads open.voidloadPreset(int presetNumber) Opens the preset panel then selects the preset after a short delay (replaces legacy async preset load).Whether the bank interface is drawn, or UNREADABLE when that cannot be told.booleanopen()booleanOpens the nearest bank booth, chest, or banker.open()with an explicit outcome.voidOpens the bank preset tab.query()A fresh query over the bank's items (only meaningful while the bank is open).voidselectPreset(int presetNumber) Selects a numbered bank preset (1-based).booleanToggle the observed Note/Item control once.booleanwithdraw(int itemId, int qty) Withdrawqtyof the first bank slot matchingitemId.booleanbooleanwithdraw1(int itemId) Withdraw exactly 1 of the first bank slot matching the given item id.booleanwithdraw10(int itemId) Withdraw 10 of the first bank slot matching the given item id.booleanwithdraw5(int itemId) Withdraw 5 of the first bank slot matching the given item id.booleanwithdrawAll(int itemId) Withdraw all of the first bank slot matching the given item id.booleanwithdrawAll(String name) Withdraw all of the first bank slot matching the given display name.withdrawAllOutcome(String name) withdrawAll(String)with an explicit outcome.withdrawOutcome(int itemId, int qty) withdraw(int, int)with an explicit outcome.withdrawOutcome(String name, int qty) withdraw(String, int)with an explicit outcome.
-
Method Details
-
isOpen
public boolean isOpen()Whether the bank reads open. False also when it cannot be read, and on Impact it can read "open" after the bank has closed; useobservedOpen()for decisions, and never gate an open on this.- Returns:
- whether the bank reads open
-
openNearestBank
public boolean openNearestBank()Opens the nearest bank booth, chest, or banker.- Returns:
- true if a bank interaction was dispatched
-
open
public boolean open()- See Also:
-
toggleWithdrawNotes
public boolean toggleWithdrawNotes()Toggle the observed Note/Item control once. The caller must establish the current mode from an actual withdrawal and verify the next item; this method does not claim a desired mode. -
query
A fresh query over the bank's items (only meaningful while the bank is open).- Returns:
- the query
-
contains
public boolean contains(int... ids) - Parameters:
ids- item ids- Returns:
- whether the bank holds any of them
-
contains
- Parameters:
names- item names- Returns:
- whether the bank holds any of them
-
count
public int count(int id) - Parameters:
id- an item id- Returns:
- the quantity banked
-
count
- Parameters:
exactName- the exact item name- Returns:
- the quantity banked
-
has
True when the bank holds at least one item whose display name matchesname(case-insensitive). -
get
-
first
Same asget(Predicate).- Parameters:
pred- the test- Returns:
- the first banked item that matches, or null
-
isEmpty
public boolean isEmpty()- Returns:
- whether the bank reads empty (also true when it is closed or unreadable)
-
withdraw1
public boolean withdraw1(int itemId) Withdraw exactly 1 of the first bank slot matching the given item id. -
withdraw5
public boolean withdraw5(int itemId) Withdraw 5 of the first bank slot matching the given item id. -
withdraw10
public boolean withdraw10(int itemId) Withdraw 10 of the first bank slot matching the given item id. -
withdrawAll
public boolean withdrawAll(int itemId) Withdraw all of the first bank slot matching the given item id. On a supported server this goes through the pinned bank container and itsBANK_WITHDRAW_ALLopcode, likewithdrawAll(String). -
withdraw
public boolean withdraw(int itemId, int qty) Withdrawqtyof the first bank slot matchingitemId.On a supported server (Impact, Elorin, SpawnPK) the slot is found by id in the pinned bank container and the largest pinned
BANK_WITHDRAW_<n>button not aboveqtyis clicked (50, 100, 500 and 1000 when the server supports them), exactly likewithdraw(String, int). Elsewhere the supported quantities are 1, 5, 10 and 0/Integer.MAX_VALUE (all); any other value uses the closest lower one.- Returns:
- dispatch acceptance; verify the inventory gained the item
-
withdraw
- Parameters:
name- the item's nameqty- how many (1, 5, 10 or All map to their buttons; others use Withdraw-X)- Returns:
- dispatch acceptance; verify the inventory gained the item
-
withdrawAll
Withdraw all of the first bank slot matching the given display name. -
depositAll
public boolean depositAll(int itemId) Deposit all stacks of the given item id from inventory into the bank. -
depositAll
Deposit all stacks of the first inventory slot matching the given display name. -
deposit1
public boolean deposit1(int itemId) Deposit 1 of the given item id from inventory. -
depositInventory
public boolean depositInventory()Deposits all items currently in inventory using the "Deposit inventory" bank button.- Returns:
- true if the click was dispatched
-
depositEquipment
public boolean depositEquipment()Deposits all worn equipment using the "Deposit worn items" bank button.- Returns:
- true if the click was dispatched; false on a server where this button cannot be clicked yet
-
close
public boolean close()Closes the bank interface. Not gated onisOpen()— that read lies or misses on Impact.- Returns:
- true if the click was dispatched (not proof the interface hid)
-
isBankOpen
Deprecated.useisOpen()(orobservedOpen()to tell "closed" from "cannot tell")Alias ofisOpen().- Returns:
- the same answer as
isOpen()
-
closeBank
-
depositItem
public boolean depositItem(int slot, int itemId) Deposits one inventory stack fromslot(same menu shape as legacy bank deposit-by-slot). -
openPresetInterface
public void openPresetInterface()Opens the bank preset tab. -
selectPreset
public void selectPreset(int presetNumber) Selects a numbered bank preset (1-based). Preset 1 uses param0 0, etc. -
loadPreset
public void loadPreset(int presetNumber) Opens the preset panel then selects the preset after a short delay (replaces legacy async preset load). -
bankerAction
public static void bankerAction()Last-resort banker interaction when no bank object is found (server-specific; uses injected adapter). -
find
-
countAll
public static int countAll(int id) Static count through the process-wide adapter; preferctx.bank.count(id).- Parameters:
id- an item id- Returns:
- the quantity banked
-
countAll
Static count through the process-wide adapter; preferctx.bank.count(name).- Parameters:
exactName- the exact item name- Returns:
- the quantity banked
-
openOutcome
-
withdrawOutcome
withdraw(String, int)with an explicit outcome. -
withdrawOutcome
withdraw(int, int)with an explicit outcome. -
withdrawAllOutcome
withdrawAll(String)with an explicit outcome. -
depositAllOutcome
depositAll(String)with an explicit outcome. -
depositAllOutcome
depositAll(int)with an explicit outcome. -
depositInventoryOutcome
depositInventory()with an explicit outcome. -
depositEquipmentOutcome
depositEquipment()with an explicit outcome. -
closeOutcome
-
observedOpen
Whether the bank interface is drawn, or UNREADABLE when that cannot be told.On Impact, Elorin and SpawnPK this answers only from whether the client is drawing the bank interface; when that cannot be told it is UNREADABLE, never the stale "open" that
isOpen()can report on Impact once the bank has been opened in the session.Never gate an open on this reading "closed"; dispatch the open and let the withdraw prove it.
- Returns:
- TRUE / FALSE, or UNREADABLE
-
close()