Package rs.kreme.ksbot.api.hooks
Class Bank
- java.lang.Object
-
- rs.kreme.ksbot.api.hooks.Items
-
- rs.kreme.ksbot.api.hooks.Bank
-
public class Bank extends Items
The Bank class represents the player's bank in the RuneScape game. It extends the Items class and implements KSContext, providing methods for interacting with the bank's inventory.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
Bank.DepositBox
Inner class representing the deposit box interface.class
Bank.Inventory
Inner class representing the player's inventory when the bank is open.static class
Bank.WithdrawMode
Represents the different modes for withdrawing items from the bank.
-
Field Summary
Fields Modifier and Type Field Description Bank.DepositBox
depositBox
Bank.Inventory
inventory
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
bankDistance()
Gets the distance to the closest bank.void
close()
Closes the bank interface by simulating an ESC key press.int
currentTab()
Gets the currently active bank tab.void
deposit(int id, int amount)
Deposits a specified quantity of an item from the inventory by ID.void
deposit(java.lang.String item, int amount)
Deposits a specified quantity of an item from the inventory by name.void
deposit(java.util.function.Predicate<KSItem> filter, int amount)
Deposits a specified quantity of an item from the inventory based on a filter.void
depositAll(java.lang.String... list)
Deposits all items in the inventory that match the provided names.void
depositAllExcept(int... items)
Deposits all items from the inventory except for the ones specified by ID.void
depositAllExcept(java.lang.String... items)
Deposits all items from the inventory except for the ones specified.void
depositEquipment()
Deposits all equipped items into the bank or deposit box, depending on which is open.void
depositInventory()
Deposits the entire inventory into the bank or deposit box, depending on which is open.void
depositLootingBag()
Deposits the looting bag contents into the bank.int
getCapacity()
Retrieves the total capacity of the bank (maximum number of slots).java.lang.Object
getClosestBank()
Gets the closest bank entity (NPC or object) to the player.int
getFreeSlots()
Retrieves the number of free slots available in the bank.int
getOccupiedSlots()
Retrieves the number of occupied slots in the bank.int[]
getTabs()
Gets an array of all available bank tabs.boolean
isDepositBoxOpen()
Checks if the DepositBox is currently open.boolean
isNotedWithdrawMode()
Checks if the bank is currently set to withdraw items as notes.boolean
isOpen()
Checks if the bank is open by verifying if the bank widget is usable.boolean
openBank()
Opens the bank by interacting with the closest banker or bank chest.int
openBank(java.lang.Object bank)
Opens the bank by interacting with a specified banker or bank chest.boolean
openTab(int tab)
Opens a specific bank tab.void
setWithdrawMode(boolean noted)
Sets the withdrawal mode for the bank interface, allowing the user to choose between withdrawing noted items or regular items.void
withdraw(int id, int amount, Bank.WithdrawMode withdrawMode)
Withdraws a specified quantity of an item from the bank by ID.void
withdraw(java.lang.String item, int amount, Bank.WithdrawMode withdrawMode)
Withdraws a specified quantity of an item from the bank by name.void
withdraw(java.util.function.Predicate<KSItem> filter, int amount, Bank.WithdrawMode withdrawMode)
Withdraws an item from a container (e.g., bank, inventory) based on a specified filter, amount, and mode.-
Methods inherited from class rs.kreme.ksbot.api.hooks.Items
contains, contains, contains, containsAll, containsAll, getCount, getCount, getEmptySlots, getItem, isEmpty, isFull, query, size
-
-
-
-
Field Detail
-
inventory
public Bank.Inventory inventory
-
depositBox
public Bank.DepositBox depositBox
-
-
Constructor Detail
-
Bank
public Bank(KSContext ctx)
-
-
Method Detail
-
isOpen
public boolean isOpen()
Checks if the bank is open by verifying if the bank widget is usable.- Returns:
- true if the bank is open, false otherwise.
-
isDepositBoxOpen
public boolean isDepositBoxOpen()
Checks if the DepositBox is currently open.- Returns:
- true if the DepositBox is open, false otherwise.
-
close
public void close()
Closes the bank interface by simulating an ESC key press.
-
getFreeSlots
public int getFreeSlots()
Retrieves the number of free slots available in the bank.- Returns:
- the number of free slots in the bank, or -1 if the bank is not open or the information is unavailable.
-
getCapacity
public int getCapacity()
Retrieves the total capacity of the bank (maximum number of slots).- Returns:
- the total capacity of the bank, or -1 if the information is unavailable or the bank is not open.
-
getOccupiedSlots
public int getOccupiedSlots()
Retrieves the number of occupied slots in the bank.- Returns:
- the number of occupied slots, or -1 if the information is unavailable or the bank is not open.
-
getClosestBank
public java.lang.Object getClosestBank()
Gets the closest bank entity (NPC or object) to the player.- Returns:
- The closest bank entity, or null if none is found
-
bankDistance
public int bankDistance()
Gets the distance to the closest bank.- Returns:
- Distance to the closest bank, or -1 if no bank was found
-
openBank
public boolean openBank()
Opens the bank by interacting with the closest banker or bank chest.- Returns:
- true if the bank was successfully opened, false otherwise.
-
openBank
public int openBank(java.lang.Object bank)
Opens the bank by interacting with a specified banker or bank chest.- Parameters:
bank
- the bank NPC or object to interact with.- Returns:
- the distance to the bank NPC or object, or -1 if invalid.
-
deposit
public void deposit(java.util.function.Predicate<KSItem> filter, int amount)
Deposits a specified quantity of an item from the inventory based on a filter.- Parameters:
filter
- the criteria to identify the item in the inventory.amount
- the number of items to deposit.
-
deposit
public void deposit(int id, int amount)
Deposits a specified quantity of an item from the inventory by ID.- Parameters:
id
- the ID of the item.amount
- the number of items to deposit.
-
deposit
public void deposit(java.lang.String item, int amount)
Deposits a specified quantity of an item from the inventory by name.- Parameters:
item
- the name of the item.amount
- the number of items to deposit.
-
depositAll
public void depositAll(java.lang.String... list)
Deposits all items in the inventory that match the provided names.- Parameters:
list
- the names of items to deposit.
-
withdraw
public void withdraw(java.util.function.Predicate<KSItem> filter, int amount, Bank.WithdrawMode withdrawMode)
Withdraws an item from a container (e.g., bank, inventory) based on a specified filter, amount, and mode.- Parameters:
filter
- APredicate
that matches the desired item(s) to withdraw.amount
- The quantity of the item to withdraw. Use -1 to withdraw all available items.withdrawMode
- The mode of withdrawal (e.g., ITEM or NOTE).
-
withdraw
public void withdraw(int id, int amount, Bank.WithdrawMode withdrawMode)
Withdraws a specified quantity of an item from the bank by ID.- Parameters:
id
- the ID of the item.amount
- the number of items to withdraw.withdrawMode
- The mode of withdrawal (e.g., ITEM or NOTE).
-
withdraw
public void withdraw(java.lang.String item, int amount, Bank.WithdrawMode withdrawMode)
Withdraws a specified quantity of an item from the bank by name.- Parameters:
item
- the name of the item.amount
- the number of items to withdraw.withdrawMode
- The mode of withdrawal (e.g., ITEM or NOTE).
-
setWithdrawMode
public void setWithdrawMode(boolean noted)
Sets the withdrawal mode for the bank interface, allowing the user to choose between withdrawing noted items or regular items.- Parameters:
noted
- If true, sets the mode to withdraw noted items; if false, sets the mode to withdraw regular items.
-
depositLootingBag
public void depositLootingBag()
Deposits the looting bag contents into the bank.
-
depositInventory
public void depositInventory()
Deposits the entire inventory into the bank or deposit box, depending on which is open.
-
depositEquipment
public void depositEquipment()
Deposits all equipped items into the bank or deposit box, depending on which is open.
-
depositAllExcept
public void depositAllExcept(java.lang.String... items)
Deposits all items from the inventory except for the ones specified.- Parameters:
items
- the names of items to exclude from depositing.
-
depositAllExcept
public void depositAllExcept(int... items)
Deposits all items from the inventory except for the ones specified by ID.- Parameters:
items
- the IDs of items to exclude from depositing.
-
isNotedWithdrawMode
public boolean isNotedWithdrawMode()
Checks if the bank is currently set to withdraw items as notes.- Returns:
- true if the withdraw-as-note mode is active, false otherwise
-
currentTab
public int currentTab()
Gets the currently active bank tab.- Returns:
- the index of the current bank tab
-
openTab
public boolean openTab(int tab)
Opens a specific bank tab.- Parameters:
tab
- the tab index to open- Returns:
- true if the tab was opened successfully, false otherwise
-
getTabs
public int[] getTabs()
Gets an array of all available bank tabs.- Returns:
- an array of tab indices
-
-