Package net.storm.sdk.items
Class Inventory
java.lang.Object
net.storm.sdk.items.Inventory
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancontains(int... id) Checks if the inventory contains any item matching any of the specified IDs.static booleanChecks if the inventory contains any item matching any of the specified names.static booleanChecks if the inventory contains any item matching the specified filter.static booleancontainsAll(int... ids) Checks if the inventory contains all items with the specified IDs.static booleancontainsAll(String... names) Checks if the inventory contains all items with the specified names.static IInventoryItemget(int slot) Gets the inventory item at the specified slot.static List<IInventoryItem> getAll()Gets all items currently in the inventory.static List<IInventoryItem> getAll(int... ids) Gets all items in the inventory matching any of the specified IDs.static List<IInventoryItem> Gets all items in the inventory matching any of the specified names.static List<IInventoryItem> getAll(Predicate<? super IInventoryItem> filter) Gets all items in the inventory matching the specified filter.static intgetCount(boolean stacks, int... ids) Counts items in the inventory matching any of the specified IDs.static intCounts items in the inventory matching any of the specified names.static intgetCount(boolean stacks, Predicate<? super IInventoryItem> filter) Counts items in the inventory matching the filter.static intgetCount(int... ids) Counts the number of inventory slots occupied by items matching any of the specified IDs.static intCounts the number of inventory slots occupied by items matching any of the specified names.static intgetCount(Predicate<? super IInventoryItem> filter) Counts the number of inventory slots occupied by items matching the filter.static IInventoryItemgetFirst(int... ids) Gets the first item in the inventory matching any of the specified IDs.static IInventoryItemGets the first item in the inventory matching any of the specified names.static IInventoryItemgetFirst(Predicate<? super IInventoryItem> filter) Gets the first item in the inventory matching the specified filter.static intGets the number of free slots in the inventory.static IInventoryItemgetLast(int... ids) Gets the last item in the inventory matching any of the specified IDs.static IInventoryItemGets the last item in the inventory matching any of the specified names.static IInventoryItemgetLast(Predicate<? super IInventoryItem> filter) Gets the last item in the inventory matching the specified filter.static booleanisEmpty()Checks if the inventory is completely empty.static booleanisFull()Checks if the inventory is full (all 28 slots occupied).
-
Constructor Details
-
Inventory
public Inventory()
-
-
Method Details
-
getAll
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
Gets all items currently in the inventory.- Returns:
- a list of all inventory items
-
getAll
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
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
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
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
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
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
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
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
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
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
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
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
Counts items in the inventory matching the filter.- Parameters:
stacks- if true, counts the total quantity of stacked items; if false, counts number of slotsfilter- 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 slotsids- the item IDs to count- Returns:
- the count of matching items
-
getCount
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 slotsnames- the item names to count- Returns:
- the count of matching items
-
getCount
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
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)
-