Class 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.
    • Constructor Summary

      Constructors 
      Constructor Description
      Bank​(KSContext ctx)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int bankDistance()  
      void close()
      Closes the bank interface by simulating an ESC key press.
      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 entire inventory into the bank or deposit box, depending on which is open.
      int getCapacity()
      Retrieves the total capacity of the bank (maximum number of slots).
      java.lang.Object getClosestBank()  
      int getFreeSlots()
      Retrieves the number of free slots available in the bank.
      int getOccupiedSlots()
      Retrieves the number of occupied slots in the bank.
      boolean isDepositBoxOpen()
      Checks if the DepositBox is currently open.
      boolean isNotedWithdrawMode()  
      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.
      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 java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • 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()
      • bankDistance

        public int bankDistance()
      • 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 - A Predicate 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 entire inventory into the bank or deposit box, depending on which is open.
      • 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()