Class DepositBoxService


  • @Singleton
    public class DepositBoxService
    extends java.lang.Object
    Service class for managing interactions with the bank deposit box interface within the client.

    The DepositBoxService provides various methods to interact with the deposit box interface, allowing users to manage their inventory, worn items, and other specific interactions associated with the deposit functionality.

    All interactions assume the deposit box interface is open from the client's context. Failing to meet this prerequisite may result in operation failure.

    Key Features:

    • Checking the state of the deposit box interface (open/closed).
    • Depositing all inventory items into the bank deposit box.
    • Depositing worn items or specific worn equipment based on slot, item ID, or name.
    • Depositing items from the looting bag into the deposit box.

    The service utilizes a context provider (@ctxProvider) to locate relevant widgets and execute interaction commands within the game client. Proper widget interaction ensures seamless deposit operations and the appropriate state handling for the deposit box interface.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean close()
      Closes the bank deposit box interface if it is currently open.
      boolean depositAll()
      Deposits all items from the player's inventory into the bank deposit box.
      boolean depositLootingBag()
      Deposits all items from the looting bag into the bank deposit box.
      boolean depositWorn​(int id)
      Deposits a specific worn equipment item into the bank deposit box based on the item ID.
      boolean depositWorn​(java.lang.String name)
      Deposits an item currently equipped on the player into a storage system.
      boolean depositWorn​(net.runelite.api.EquipmentInventorySlot slot)
      Deposits a specific worn equipment item from the player's inventory into the bank deposit box.
      boolean depositWornItems()
      Deposits all worn items from the player's equipment into the bank deposit box.
      int getDepositBoxWidget​(net.runelite.api.EquipmentInventorySlot slot)
      Retrieves the interface widget ID corresponding to a deposit box slot for the specified EquipmentInventorySlot.
      boolean isClosed()
      Determines whether the bank deposit box interface is currently closed.
      boolean isOpen()
      Determines whether the bank deposit box interface is currently open.
      boolean setQuantity​(int amount)
      Sets the deposit quantity in the bank deposit box interface to the specified amount.
      • Methods inherited from class java.lang.Object

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

      • DepositBoxService

        public DepositBoxService()
    • Method Detail

      • isOpen

        public boolean isOpen()
        Determines whether the bank deposit box interface is currently open.

        This method verifies if the corresponding widget for the deposit box frame is visible to the user within the client.

        Returns:
        true if the deposit box interface is open; false otherwise.
      • isClosed

        public boolean isClosed()
        Determines whether the bank deposit box interface is currently closed.

        This method performs the inverse check of isOpen() to determine if the deposit box interface is not visible to the user.

        Returns:
        true if the deposit box interface is closed; false otherwise.
      • close

        public boolean close()
        Closes the bank deposit box interface if it is currently open.

        This method checks if the deposit box interface is already closed by invoking isClosed(). If the interface is open, it attempts to close it by executing a client script.

        The operation will return true if the interface is successfully verified as closed or was already closed before the method was invoked.

        Returns:
        true if the deposit box interface is closed (either already closed or successfully closed); false if the operation cannot determine the state of the interface or failed to close it.
      • depositAll

        public boolean depositAll()
        Deposits all items from the player's inventory into the bank deposit box.

        This method interacts with the deposit box interface in the game client to move all inventory items into the bank. It utilizes the @ctxProvider to access the relevant game widgets and send the interaction command.

        The method assumes that the deposit box interface is already open and accessible for interaction. If the interface is not open, the operation may fail.

        Returns:
        true if the interaction with the deposit box to deposit all items is successful; false otherwise.
      • depositWornItems

        public boolean depositWornItems()
        Deposits all worn items from the player's equipment into the bank deposit box.

        This method interacts with the deposit box interface widget in the game client to move all items currently equipped by the player into the bank. It uses the @ctxProvider to access the relevant widget component and send the interaction command.

        The method assumes that the deposit box interface is already open and accessible for interaction. If the interface is not open, the operation may fail.

        The widget interaction is performed using the @BankDepositbox.DEPOSIT_WORN constant and invokes the interaction index 1 for depositing worn items.

        Returns:
        true if the interaction was successfully executed and worn items were deposited; false otherwise if the interaction fails or conditions are not met.
      • depositLootingBag

        public boolean depositLootingBag()
        Deposits all items from the looting bag into the bank deposit box.

        This method interacts with the specific widget representing the "Deposit Looting Bag" option in the bank deposit box interface. It uses the @ctxProvider to access the widget and perform the interaction.

        • The operation assumes that the bank deposit box interface is already open and accessible.
        • If the interface is not open, the interaction may fail.
        Returns:
        true if the interaction with the "Deposit Looting Bag" widget is successful; false otherwise if the widget is not found or the interaction fails.
      • depositWorn

        public boolean depositWorn​(net.runelite.api.EquipmentInventorySlot slot)
        Deposits a specific worn equipment item from the player's inventory into the bank deposit box.

        This method interacts with the deposit box interface to deposit a single worn equipment item specified by its EquipmentInventorySlot. It uses the @ctxProvider to locate the corresponding widget and perform the interaction.

        • The method interacts with the specific slot's widget, which corresponds to the player's equipped item to be deposited.
        • The deposit box interface must be open and accessible for this operation to succeed. If the interface is not open, the interaction will fail.
        Parameters:
        slot - the EquipmentInventorySlot representing the specific item to be deposited. This parameter identifies the equipment slot (e.g., Helmet, Chest, Gloves) for the item to be interacted with.
        Returns:
        true if the deposit operation on the specified worn item is successful; false if the interaction fails or the required conditions are not met (e.g., the deposit box is not open, or the widget is unavailable).
      • depositWorn

        public boolean depositWorn​(int id)
        Deposits a specific worn equipment item into the bank deposit box based on the item ID.

        This method retrieves the worn equipment item associated with the given id from the player's equipment. If the item is found and associated with a valid EquipmentInventorySlot, it attempts to deposit the item into the bank deposit box.

        • The deposit operation is performed on the specific slot that corresponds to the equipment item with the provided id.
        • The operation assumes the deposit box interface is already open; otherwise, the interaction may fail.
        • If the item or its corresponding slot is not found, the method returns false.
        Parameters:
        id - the unique identifier of the equipment item to be deposited. This represents the item to locate in the player's worn equipment slots.
        Returns:
        true if the interaction to deposit the worn item succeeds; false otherwise, such as when the item or slot is not found, or the deposit operation fails.
      • depositWorn

        public boolean depositWorn​(java.lang.String name)
        Deposits an item currently equipped on the player into a storage system.

        This method attempts to locate an equipped item by its name and then identifies its respective equipment slot. If both are valid, the item is deposited.

        Parameters:
        name - The name of the equipped item to be deposited.

        This parameter specifies the exact name of the item as it appears in the game's interface or inventory system.

        Returns:
        true if the item was successfully deposited; false if the item could not be located or deposited.
      • getDepositBoxWidget

        public int getDepositBoxWidget​(net.runelite.api.EquipmentInventorySlot slot)
        Retrieves the interface widget ID corresponding to a deposit box slot for the specified EquipmentInventorySlot.

        This method maps equipment slots to their respective widget IDs used in the deposit box interface. If the specified slot does not match a known equipment slot, an IllegalArgumentException is thrown.

        Parameters:
        slot - The EquipmentInventorySlot representing the equipment slot for which the deposit box widget ID is to be retrieved.
        • @code HEAD maps to @code SLOT0
        • @code CAPE maps to @code SLOT1
        • @code AMULET maps to @code SLOT2
        • @code WEAPON maps to @code SLOT3
        • @code BODY maps to @code SLOT4
        • @code SHIELD maps to @code SLOT5
        • @code LEGS maps to @code SLOT7
        • @code GLOVES maps to @code SLOT9
        • @code BOOTS maps to @code SLOT10
        • @code RING maps to @code SLOT12
        • @code AMMO maps to @code SLOT13
        Returns:
        The interface widget ID as an integer that corresponds to the provided EquipmentInventorySlot.
        Throws:
        java.lang.IllegalArgumentException - If an unknown or unsupported EquipmentInventorySlot is provided.
      • setQuantity

        public boolean setQuantity​(int amount)
        Sets the deposit quantity in the bank deposit box interface to the specified amount.

        This method interacts with the game client's deposit box interface to set the quantity of items to be deposited or withdrawn. It supports predefined options such as 1, 5, 10, and ALL, as well as a custom quantity input via numerical dialogue for other values.

        • 1: Sets the quantity to deposit or withdraw 1 item.
        • 5: Sets the quantity to deposit or withdraw 5 items.
        • 10: Sets the quantity to deposit or withdraw 10 items.
        • ALL: Deposits or withdraws all items.
        • Other values: Prompts a numeric input dialogue to specify the desired quantity.

        If the specified amount is not among the predefined options, the method invokes a dialogue service to continue with a custom quantity input.

        Parameters:
        amount - the quantity to set in the deposit box interface. Acceptable values are 1, 5, 10, -1 (for ALL), or any positive integer for custom input.
        Returns:
        true if the operation to set the quantity or initiate the numerical dialogue is successful; false otherwise.