Class Bank

java.lang.Object
privbot.hooks.Bank

public final class Bank extends Object
Bank queries and interactions through the game client.

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 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; use observedOpen() 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

      public ItemQuery 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

      public boolean contains(String... names)
      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

      public int count(String exactName)
      Parameters:
      exactName - the exact item name
      Returns:
      the quantity banked
    • has

      public boolean has(String name)
      True when the bank holds at least one item whose display name matches name (case-insensitive).
    • get

      public PrivItem get(Predicate<PrivItem> pred)
      Parameters:
      pred - the test
      Returns:
      the first banked item that matches, or null
    • first

      public PrivItem first(Predicate<PrivItem> pred)
      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 its BANK_WITHDRAW_ALL opcode, like withdrawAll(String).
    • withdraw

      public boolean withdraw(int itemId, int qty)
      Withdraw qty of the first bank slot matching itemId.

      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 above qty is clicked (50, 100, 500 and 1000 when the server supports them), exactly like withdraw(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

      public boolean withdraw(String name, int qty)
      Parameters:
      name - the item's name
      qty - 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

      public boolean withdrawAll(String name)
      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

      public boolean depositAll(String name)
      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 on isOpen() — that read lies or misses on Impact.
      Returns:
      true if the click was dispatched (not proof the interface hid)
    • isBankOpen

      @Deprecated public boolean isBankOpen()
      Deprecated.
      use isOpen() (or observedOpen() to tell "closed" from "cannot tell")
      Alias of isOpen().
      Returns:
      the same answer as isOpen()
    • closeBank

      @Deprecated public boolean closeBank()
      Deprecated.
      Alias of close().
      Returns:
      the same answer as close()
    • depositItem

      public boolean depositItem(int slot, int itemId)
      Deposits one inventory stack from slot (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

      public static PrivItem find(Predicate<PrivItem> pred)
      Static lookup through the process-wide adapter; prefer ctx.bank.get(pred).
      Parameters:
      pred - the test
      Returns:
      the first banked item that matches, or null
    • countAll

      public static int countAll(int id)
      Static count through the process-wide adapter; prefer ctx.bank.count(id).
      Parameters:
      id - an item id
      Returns:
      the quantity banked
    • countAll

      public static int countAll(String exactName)
      Static count through the process-wide adapter; prefer ctx.bank.count(name).
      Parameters:
      exactName - the exact item name
      Returns:
      the quantity banked
    • openOutcome

      public Outcome openOutcome()
      open() with an explicit outcome.
    • withdrawOutcome

      public Outcome withdrawOutcome(String name, int qty)
      withdraw(String, int) with an explicit outcome.
    • withdrawOutcome

      public Outcome withdrawOutcome(int itemId, int qty)
      withdraw(int, int) with an explicit outcome.
    • withdrawAllOutcome

      public Outcome withdrawAllOutcome(String name)
      withdrawAll(String) with an explicit outcome.
    • depositAllOutcome

      public Outcome depositAllOutcome(String name)
      depositAll(String) with an explicit outcome.
    • depositAllOutcome

      public Outcome depositAllOutcome(int itemId)
      depositAll(int) with an explicit outcome.
    • depositInventoryOutcome

      public Outcome depositInventoryOutcome()
      depositInventory() with an explicit outcome.
    • depositEquipmentOutcome

      public Outcome depositEquipmentOutcome()
      depositEquipment() with an explicit outcome.
    • closeOutcome

      public Outcome closeOutcome()
      close() with an explicit outcome. Not gated on isOpen(), like close().
    • observedOpen

      public Observed<Boolean> 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