Class Inventory

java.lang.Object
net.storm.sdk.items.Inventory

public class Inventory extends Object
Static utility class for accessing and interacting with the player's inventory.

The inventory holds up to 28 items. This class provides methods to query items, check for specific items, count quantities, and perform item interactions.

Example usage:

 
 // Check if inventory has food
 if (Inventory.contains("Lobster", "Shark")) {
     IInventoryItem food = Inventory.getFirst("Lobster", "Shark");
     food.interact("Eat");
 }

 // Count coins
 int coins = Inventory.getCount(995);

 // Check inventory space
 if (!Inventory.isFull()) {
     // Can pick up more items
 }

 // Use item on another
 IInventoryItem herb = Inventory.getFirst("Guam leaf");
 IInventoryItem vial = Inventory.getFirst("Vial of water");
 herb.useOn(vial);
 
 

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    contains(int... id)
    Checks if the inventory contains any item matching any of the specified IDs.
    static boolean
    contains(String... name)
    Checks if the inventory contains any item matching any of the specified names.
    static boolean
    contains(Predicate<? super IItem> filter)
    Checks if the inventory contains any item matching the specified filter.
    static boolean
    containsAll(int... ids)
    Checks if the inventory contains all items with the specified IDs.
    static boolean
    containsAll(String... names)
    Checks if the inventory contains all items with the specified names.
    get(int slot)
    Gets the inventory item at the specified slot.
    Gets all items currently in the inventory.
    getAll(int... ids)
    Gets all items in the inventory matching any of the specified IDs.
    getAll(String... names)
    Gets all items in the inventory matching any of the specified names.
    getAll(Predicate<? super IInventoryItem> filter)
    Gets all items in the inventory matching the specified filter.
    static int
    getCount(boolean stacks, int... ids)
    Counts items in the inventory matching any of the specified IDs.
    static int
    getCount(boolean stacks, String... names)
    Counts items in the inventory matching any of the specified names.
    static int
    getCount(boolean stacks, Predicate<? super IInventoryItem> filter)
    Counts items in the inventory matching the filter.
    static int
    getCount(int... ids)
    Counts the number of inventory slots occupied by items matching any of the specified IDs.
    static int
    getCount(String... names)
    Counts the number of inventory slots occupied by items matching any of the specified names.
    static int
    Counts the number of inventory slots occupied by items matching the filter.
    getFirst(int... ids)
    Gets the first item in the inventory matching any of the specified IDs.
    getFirst(String... names)
    Gets the first item in the inventory matching any of the specified names.
    Gets the first item in the inventory matching the specified filter.
    static int
    Gets the number of free slots in the inventory.
    getLast(int... ids)
    Gets the last item in the inventory matching any of the specified IDs.
    getLast(String... names)
    Gets the last item in the inventory matching any of the specified names.
    getLast(Predicate<? super IInventoryItem> filter)
    Gets the last item in the inventory matching the specified filter.
    static boolean
    Checks if the inventory is completely empty.
    static boolean
    Checks if the inventory is full (all 28 slots occupied).

    Methods inherited from class java.lang.Object

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

    • Inventory

      public Inventory()
  • Method Details

    • getAll

      public static List<IInventoryItem> getAll(Predicate<? super IInventoryItem> filter)
      Gets all items in the inventory matching the specified filter.
      Parameters:
      filter - the predicate to match items against
      Returns:
      a list of matching inventory items
    • getAll

      public static List<IInventoryItem> getAll()
      Gets all items currently in the inventory.
      Returns:
      a list of all inventory items
    • getAll

      public static List<IInventoryItem> getAll(int... ids)
      Gets all items in the inventory matching any of the specified IDs.
      Parameters:
      ids - the item IDs to search for
      Returns:
      a list of matching inventory items
    • getAll

      public static List<IInventoryItem> getAll(String... names)
      Gets all items in the inventory matching any of the specified names.
      Parameters:
      names - the item names to search for
      Returns:
      a list of matching inventory items
    • get

      public static IInventoryItem get(int slot)
      Gets the inventory item at the specified slot.
      Parameters:
      slot - the slot index (0-27)
      Returns:
      the inventory item at the slot, or null if empty
    • getFirst

      public static IInventoryItem getFirst(Predicate<? super IInventoryItem> filter)
      Gets the first item in the inventory matching the specified filter.
      Parameters:
      filter - the predicate to match items against
      Returns:
      the first matching inventory item, or null if none found
    • getFirst

      public static IInventoryItem getFirst(int... ids)
      Gets the first item in the inventory matching any of the specified IDs.
      Parameters:
      ids - the item IDs to search for
      Returns:
      the first matching inventory item, or null if none found
    • getFirst

      public static IInventoryItem getFirst(String... names)
      Gets the first item in the inventory matching any of the specified names.
      Parameters:
      names - the item names to search for
      Returns:
      the first matching inventory item, or null if none found
    • getLast

      public static IInventoryItem getLast(Predicate<? super IInventoryItem> filter)
      Gets the last item in the inventory matching the specified filter.
      Parameters:
      filter - the predicate to match items against
      Returns:
      the last matching inventory item, or null if none found
    • getLast

      public static IInventoryItem getLast(int... ids)
      Gets the last item in the inventory matching any of the specified IDs.
      Parameters:
      ids - the item IDs to search for
      Returns:
      the last matching inventory item, or null if none found
    • getLast

      public static IInventoryItem getLast(String... names)
      Gets the last item in the inventory matching any of the specified names.
      Parameters:
      names - the item names to search for
      Returns:
      the last matching inventory item, or null if none found
    • contains

      public static boolean contains(Predicate<? super IItem> filter)
      Checks if the inventory contains any item matching the specified filter.
      Parameters:
      filter - the predicate to match items against
      Returns:
      true if at least one matching item exists, false otherwise
    • contains

      public static boolean contains(int... id)
      Checks if the inventory contains any item matching any of the specified IDs.
      Parameters:
      id - the item IDs to search for
      Returns:
      true if at least one matching item exists, false otherwise
    • contains

      public static boolean contains(String... name)
      Checks if the inventory contains any item matching any of the specified names.
      Parameters:
      name - the item names to search for
      Returns:
      true if at least one matching item exists, false otherwise
    • containsAll

      public static boolean containsAll(int... ids)
      Checks if the inventory contains all items with the specified IDs.
      Parameters:
      ids - the item IDs that must all be present
      Returns:
      true if all items are present, false if any are missing
    • containsAll

      public static boolean containsAll(String... names)
      Checks if the inventory contains all items with the specified names.
      Parameters:
      names - the item names that must all be present
      Returns:
      true if all items are present, false if any are missing
    • getCount

      public static int getCount(boolean stacks, Predicate<? super IInventoryItem> filter)
      Counts items in the inventory matching the filter.
      Parameters:
      stacks - if true, counts the total quantity of stacked items; if false, counts number of slots
      filter - the predicate to match items against
      Returns:
      the count of matching items
    • getCount

      public static int getCount(boolean stacks, int... ids)
      Counts items in the inventory matching any of the specified IDs.
      Parameters:
      stacks - if true, counts the total quantity of stacked items; if false, counts number of slots
      ids - the item IDs to count
      Returns:
      the count of matching items
    • getCount

      public static int getCount(boolean stacks, String... names)
      Counts items in the inventory matching any of the specified names.
      Parameters:
      stacks - if true, counts the total quantity of stacked items; if false, counts number of slots
      names - the item names to count
      Returns:
      the count of matching items
    • getCount

      public static int getCount(Predicate<? super IInventoryItem> filter)
      Counts the number of inventory slots occupied by items matching the filter.
      Parameters:
      filter - the predicate to match items against
      Returns:
      the number of matching slots
    • getCount

      public static int getCount(int... ids)
      Counts the number of inventory slots occupied by items matching any of the specified IDs.
      Parameters:
      ids - the item IDs to count
      Returns:
      the number of matching slots
    • getCount

      public static int getCount(String... names)
      Counts the number of inventory slots occupied by items matching any of the specified names.
      Parameters:
      names - the item names to count
      Returns:
      the number of matching slots
    • isFull

      public static boolean isFull()
      Checks if the inventory is full (all 28 slots occupied).
      Returns:
      true if the inventory has no free slots, false otherwise
    • isEmpty

      public static boolean isEmpty()
      Checks if the inventory is completely empty.
      Returns:
      true if the inventory has no items, false otherwise
    • getFreeSlots

      public static int getFreeSlots()
      Gets the number of free slots in the inventory.
      Returns:
      the number of empty slots (0-28)