Package rsb.methods

Class Inventory


public class Inventory extends MethodProvider
Inventory related operations.
Author:
GigiaJ
  • Field Summary

    Fields inherited from class rsb.methods.MethodProvider

    methods
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Uses a callback to get the last drawn image and then performs the method getSelected to update the isSelectedValue
    boolean
    Left-clicks on the selected item.
    boolean
    clickSelectedItem(boolean leftClick)
    Clicks selected inventory item, if it's selected.
    boolean
    contains(int itemID)
    Checks whether your inventory contains the provided item ID.
    boolean
    Checks whether your inventory contains the provided item name.
    boolean
    containsAll(int... itemID)
    Checks whether your inventory contains all of the provided item IDs.
    boolean
    containsAll(String... names)
    Checks whether your inventory contains all of the provided item IDs.
    boolean
    containsOneOf(int... itemID)
    Checks whether your inventory contains at least one of the provided item IDs.
    boolean
    Checks whether your inventory contains at least one of the provided item names.
    boolean
    destroyItem(int itemID)
    Destroys any inventory items with the given ID.
    boolean
    Destroys any inventory items with the given name.
    void
    dropAllExcept(boolean leftToRight, int... items)
    Drops all items with the same specified id.
    void
    dropAllExcept(boolean leftToRight, String... names)
    Drops all items with the specified names.
    boolean
    dropAllExcept(int... items)
    Drops all items with the same specified id.
    boolean
    Drops all items with the specified names.
    boolean
    dropItem(int col, int row)
    Drops the item in the specified column and row.
     
    Gets all the items in the inventory.
    int
    Gets the count of all items in your inventory ignoring stack sizes.
    int
    getCount(boolean includeStacks)
    Gets the count of all items in your inventory.
    int
    getCount(boolean includeStacks, int... itemIDs)
    Gets the count of all the items in the inventory with the any of the specified IDs.
    int
    getCount(boolean includeStacks, String... names)
    Gets the count of all the items in the inventory with the any of the specified names.
    int
    getCount(int... itemIDs)
    Gets the count of all the items in the inventory with the any of the specified IDs.
    int
    getCount(String... names)
    Gets the count of all the items in the inventory with the any of the specified names.
    int
    getCountExcept(boolean includeStacks, int... ids)
    Gets the count of all the items in the inventory without any of the provided IDs.
    int
    getCountExcept(boolean includeStacks, String... names)
    Gets the count of all the items in the inventory without any of the provided names.
    int
    getCountExcept(int... ids)
    Gets the count of all the items in the inventory without any of the provided IDs.
    int
    Gets the count of all the items in the inventory without any of the provided names.
    Gets the inventory interface.
    getItem(int... ids)
    Gets the first item in the inventory with any of the provided IDs.
    getItem(String... names)
    Gets the first item in the inventory with any of the provided names.
    getItemAt(int index)
    Gets inventory item at specified index.
    int
    Gets the ID of an item in the inventory with a given name.
    int[]
    getItemIDs(String[] names)
    Gets the IDs of items in the inventory with given names.
    Gets all the items in the inventory.
    getItems(int... ids)
    Gets all the items in the inventory matching any of the provided IDs.
    getItems(String... names)
    Gets all the items in the inventory matching any of the provided names.
    int
    Checks the image for the item position and then checks that set of bounds for any pure white pixels which would indicate that the item is selected (No items use 255, 255, 255) If it finds any the isSelected value is updated to true
    Gets the selected inventory item.
    int
    Gets the selected item index.
    Gets the selected item name.
    boolean
    Checks whether your inventory is full.
    boolean
    Checks whether an inventory item is selected.
    boolean
    itemHasAction(RSItem item, String action)
    Determines if the item contains the desired action.
    randomizeItemPoint(Point inventoryPoint)
    Randomizes a point.
    boolean
    selectItem(int itemID)
    Selects the first item in the inventory with the provided ID.
    boolean
    Selects the first item in the inventory with the provided name.
    boolean
    Selects the specified item in the inventory
    boolean
    useItem(int itemID, int targetID)
    Uses two items together.
    boolean
    useItem(int itemID, RSObject object)
    Uses an item on an object.
    boolean
    useItem(String name, String targetName)
    Uses two items together.
    boolean
    useItem(String name, RSObject object)
    Uses an item on an object.
    boolean
    useItem(RSItem item, RSItem targetItem)
    Uses two items together.
    boolean
    useItem(RSItem item, RSObject targetObject)
    Uses an item on an object.

    Methods inherited from class rsb.methods.MethodProvider

    random, random, random, random, sleep

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getInterface

      public Map.Entry<String,RSWidget> getInterface()
      Gets the inventory interface.
      Returns:
      the inventory interface
    • destroyItem

      public boolean destroyItem(int itemID)
      Destroys any inventory items with the given ID.
      Parameters:
      itemID - The ID of items to destroy.
      Returns:
      true if the items were destroyed; otherwise false.
    • destroyItem

      public boolean destroyItem(String name)
      Destroys any inventory items with the given name.
      Parameters:
      name - The name of items to destroy.
      Returns:
      true if the items were destroyed; otherwise false.
    • dropAllExcept

      public void dropAllExcept(boolean leftToRight, int... items)
      Drops all items with the same specified id.
      Parameters:
      leftToRight - true to drop items from left to right.
      items - The item IDs to drop
    • dropAllExcept

      public void dropAllExcept(boolean leftToRight, String... names)
      Drops all items with the specified names.
      Parameters:
      leftToRight - true to drop items from left to right.
      names - The item names to drop
    • itemHasAction

      public boolean itemHasAction(RSItem item, String action)
      Determines if the item contains the desired action.
      Parameters:
      item - The item to check.
      action - The item menu action to check.
      Returns:
      true if the item has the action; otherwise false.
    • dropAllExcept

      public boolean dropAllExcept(int... items)
      Drops all items with the same specified id. This method drops items vertically going down the inventory.
      Parameters:
      items - The item IDs to drop.
      Returns:
      true at all times.
      See Also:
    • dropAllExcept

      public boolean dropAllExcept(String... names)
      Drops all items with the specified names. This method drops items vertically going down the inventory.
      Parameters:
      names - The item names to drop.
      Returns:
      true at all times.
      See Also:
    • dropItem

      public boolean dropItem(int col, int row)
      Drops the item in the specified column and row.
      Parameters:
      col - The column the item is in.
      row - The row the item is in.
      Returns:
      true if we tried to drop the item, false if not (e.g., if item is undroppable)
    • contains

      public boolean contains(int itemID)
      Checks whether your inventory contains the provided item ID.
      Parameters:
      itemID - The item(s) you wish to evaluate.
      Returns:
      true if your inventory contains an item with the ID provided; otherwise false.
      See Also:
    • contains

      public boolean contains(String name)
      Checks whether your inventory contains the provided item name.
      Parameters:
      name - The name you wish to evaluate.
      Returns:
      true if your inventory contains an item with the name provided; otherwise false.
      See Also:
    • containsAll

      public boolean containsAll(int... itemID)
      Checks whether your inventory contains all of the provided item IDs.
      Parameters:
      itemID - The item(s) you wish to evaluate.
      Returns:
      true if your inventory contains at least one of all of the item IDs provided; otherwise false.
      See Also:
    • containsAll

      public boolean containsAll(String... names)
      Checks whether your inventory contains all of the provided item IDs.
      Parameters:
      names - The item(s) you wish to evaluate.
      Returns:
      true if your inventory contains at least one of all of the item IDs provided; otherwise false.
      See Also:
    • containsOneOf

      public boolean containsOneOf(int... itemID)
      Checks whether your inventory contains at least one of the provided item IDs.
      Parameters:
      itemID - The item ID to check for.
      Returns:
      true if inventory contains one of the specified items; otherwise false.
      See Also:
    • containsOneOf

      public boolean containsOneOf(String... names)
      Checks whether your inventory contains at least one of the provided item names.
      Parameters:
      names - The item names to check for.
      Returns:
      true if inventory contains one of the specified items; otherwise false.
      See Also:
    • isFull

      public boolean isFull()
      Checks whether your inventory is full.
      Returns:
      true if your inventory contains 28 items; otherwise false.
    • isItemSelected

      public boolean isItemSelected()
      Checks whether an inventory item is selected.
      Returns:
      true if an item in your inventory is selected; otherwise false.
    • selectItem

      public boolean selectItem(int itemID)
      Selects the first item in the inventory with the provided ID.
      Parameters:
      itemID - The ID of the item to select.
      Returns:
      true if the item was selected; otherwise false.
    • selectItem

      public boolean selectItem(String name)
      Selects the first item in the inventory with the provided name.
      Parameters:
      name - The name of the item to select.
      Returns:
      true if the item was selected; otherwise false.
    • selectItem

      public boolean selectItem(RSItem item)
      Selects the specified item in the inventory
      Parameters:
      item - The item to select.
      Returns:
      true if the item was selected; otherwise false.
    • useItem

      public boolean useItem(RSItem item, RSItem targetItem)
      Uses two items together.
      Parameters:
      item - The item to use on another item.
      targetItem - The item you want the first parameter to be used on.
      Returns:
      true if the "use" action had been used on both items; otherwise false.
    • useItem

      public boolean useItem(int itemID, int targetID)
      Uses two items together.
      Parameters:
      itemID - The first item ID to use.
      targetID - The item ID you want the first parameter to be used on.
      Returns:
      true if the first item has been "used" on the other; otherwise false.
    • useItem

      public boolean useItem(String name, String targetName)
      Uses two items together.
      Parameters:
      name - The first item to use.
      targetName - The item name you want the first parameter to be used on.
      Returns:
      true if the first item has been "used" on the other; otherwise false.
    • useItem

      public boolean useItem(RSItem item, RSObject targetObject)
      Uses an item on an object.
      Parameters:
      item - The item to use on another item.
      targetObject - The RSObject you want the first parameter to be used on.
      Returns:
      true if the "use" action had been used on both the RSItem and RSObject; otherwise false.
    • useItem

      public boolean useItem(int itemID, RSObject object)
      Uses an item on an object.
      Parameters:
      itemID - The item ID to use on the object.
      object - The RSObject you want the item to be used on.
      Returns:
      true if the "use" action had been used on both the RSItem and RSObject; otherwise false.
    • useItem

      public boolean useItem(String name, RSObject object)
      Uses an item on an object.
      Parameters:
      name - The item name to use on the object.
      object - The RSObject you want the item to be used on.
      Returns:
      true if the "use" action had been used on both the RSItem and RSObject; otherwise false.
    • randomizeItemPoint

      public Point randomizeItemPoint(Point inventoryPoint)
      Randomizes a point.
      Parameters:
      inventoryPoint - The inventory point to be randomized.
      Returns:
      A randomized Point from the center of the given Point.
    • getSelectedItemName

      public String getSelectedItemName()
      Gets the selected item name.
      Returns:
      The name of the current selected item, or null if none is selected.
    • getSelectedItemIndex

      public int getSelectedItemIndex()
      Gets the selected item index.
      Returns:
      The index of current selected item, or -1 if none is selected.
    • checkIsSelected

      public int checkIsSelected(RSWidgetItem[] comps)
      Uses a callback to get the last drawn image and then performs the method getSelected to update the isSelectedValue
      Parameters:
      comps - the item to check if is selected
      Returns:
      the index of the item selected; otherwise -1
    • getSelected

      public int getSelected(Image img, RSWidgetItem[] comps)
      Checks the image for the item position and then checks that set of bounds for any pure white pixels which would indicate that the item is selected (No items use 255, 255, 255) If it finds any the isSelected value is updated to true
      Parameters:
      img - the client image
      comps - the item to check for if it is selected
      Returns:
      the index of the item selected; otherwise -1
    • getSelectedItem

      public RSItem getSelectedItem()
      Gets the selected inventory item.
      Returns:
      The current selected item, or null if none is selected.
    • clickSelectedItem

      public boolean clickSelectedItem(boolean leftClick)
      Clicks selected inventory item, if it's selected.
      Parameters:
      leftClick - true for left button click, false for right button.
      Returns:
      true if item was selected, false if not.
    • clickSelectedItem

      public boolean clickSelectedItem()
      Left-clicks on the selected item.
      Returns:
      true if item was selected, false if not.
      See Also:
    • getItemAt

      public RSItem getItemAt(int index)
      Gets inventory item at specified index.
      Parameters:
      index - The index of inventory item.
      Returns:
      The item, or null if not found.
    • getItems

      public RSItem[] getItems()
      Gets all the items in the inventory.
      Returns:
      RSItem array of the current inventory items or new RSItem[0].
    • getItems

      public RSItem[] getItems(int... ids)
      Gets all the items in the inventory matching any of the provided IDs.
      Parameters:
      ids - Valid IDs.
      Returns:
      RSItem array of the matching inventory items.
    • getItems

      public RSItem[] getItems(String... names)
      Gets all the items in the inventory matching any of the provided names.
      Parameters:
      names - Valid IDs.
      Returns:
      RSItem array of the matching inventory items.
    • getCachedItems

      public RSItem[] getCachedItems()
      Gets all the items in the inventory. If the tab is not currently open, it does not open it and returns the last known array of items in the tab.
      Returns:
      RSItem array of the cached inventory items or new RSItem[0].
    • getItemID

      public int getItemID(String name)
      Gets the ID of an item in the inventory with a given name.
      Parameters:
      name - The name of the item you wish to find.
      Returns:
      The ID of the item or -1 if not in inventory.
    • getItemIDs

      public int[] getItemIDs(String[] names)
      Gets the IDs of items in the inventory with given names.
      Parameters:
      names - The names of the item IDs you wish to find.
      Returns:
      The IDs of the items or null if not in inventory.
    • getItem

      public RSItem getItem(int... ids)
      Gets the first item in the inventory with any of the provided IDs.
      Parameters:
      ids - The IDs of the item to find.
      Returns:
      The first RSItem for the given IDs; otherwise null.
    • getItem

      public RSItem getItem(String... names)
      Gets the first item in the inventory with any of the provided names.
      Parameters:
      names - The names of the item to find.
      Returns:
      The first RSItem for the given names; otherwise null.
    • find

      public RSItem[] find(Predicate<RSItem> filter)
    • getCountExcept

      public int getCountExcept(int... ids)
      Gets the count of all the items in the inventory without any of the provided IDs. This ignores stack sizes.
      Parameters:
      ids - The item IDs to exclude.
      Returns:
      The count.
    • getCountExcept

      public int getCountExcept(String... names)
      Gets the count of all the items in the inventory without any of the provided names. This ignores stack sizes.
      Parameters:
      names - The item names to exclude.
      Returns:
      The count.
    • getCountExcept

      public int getCountExcept(boolean includeStacks, int... ids)
      Gets the count of all the items in the inventory without any of the provided IDs.
      Parameters:
      includeStacks - true to count the stack sizes of each item; false to count a stack as a single item.
      ids - The item IDs to exclude.
      Returns:
      The count.
    • getCountExcept

      public int getCountExcept(boolean includeStacks, String... names)
      Gets the count of all the items in the inventory without any of the provided names.
      Parameters:
      includeStacks - true to count the stack sizes of each item; false to count a stack as a single item.
      names - The item names to exclude.
      Returns:
      The count.
    • getCount

      public int getCount(int... itemIDs)
      Gets the count of all the items in the inventory with the any of the specified IDs. This ignores stack sizes.
      Parameters:
      itemIDs - the item IDs to include
      Returns:
      The count.
    • getCount

      public int getCount(String... names)
      Gets the count of all the items in the inventory with the any of the specified names. This ignores stack sizes.
      Parameters:
      names - the item names to include
      Returns:
      The count.
    • getCount

      public int getCount(boolean includeStacks, int... itemIDs)
      Gets the count of all the items in the inventory with the any of the specified IDs.
      Parameters:
      includeStacks - true to count the stack sizes of each item; false to count a stack as a single item.
      itemIDs - the item IDs to include
      Returns:
      The count.
    • getCount

      public int getCount(boolean includeStacks, String... names)
      Gets the count of all the items in the inventory with the any of the specified names.
      Parameters:
      includeStacks - true to count the stack sizes of each item; false to count a stack as a single item.
      names - the item names to include
      Returns:
      The count.
    • getCount

      public int getCount()
      Gets the count of all items in your inventory ignoring stack sizes.
      Returns:
      The count.
    • getCount

      public int getCount(boolean includeStacks)
      Gets the count of all items in your inventory.
      Parameters:
      includeStacks - false if stacked items should be counted as a single item; otherwise true.
      Returns:
      The count.