Package net.storm.api.items
Interface ItemProvider<T extends IItem>
- Type Parameters:
T- the type of items in this container
- All Known Subinterfaces:
IBank,IBankInventory,IEquipment,IInventory,IItems<T>,ITradeInventory,ITradeOther,ITradeOurs
public interface ItemProvider<T extends IItem>
Provides methods for querying and accessing items in a container.
This interface defines the common item query API used by inventory, bank, equipment, and other item containers. It supports filtering by:
- Item IDs
- Item names
- Custom predicates
Example usage:
// Get all food items
List<IItem> food = inventory.getAll("Lobster", "Shark", "Manta ray");
// Get first item matching a condition
IItem coins = inventory.getFirst(item -> item.getId() == 995);
// Count items
int coinCount = inventory.getCount(995); // includes stack quantity
int itemCount = inventory.getCount(false, 995); // counts as 1 regardless of stack
// Check for items
boolean hasFood = inventory.contains("Lobster", "Shark");
boolean hasAllRunes = inventory.containsAll("Air rune", "Fire rune", "Nature rune");
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleancontains(int... ids) Checks if any item has one of the specified IDs.default booleanChecks if any item has one of the specified names.default booleanChecks if any item matches the filter.default booleancontainsAll(int... ids) Checks if items exist for ALL of the specified IDs.default booleancontainsAll(String... names) Checks if items exist for ALL of the specified names.default booleancontainsAll(Predicate<? super T> filter) Checks if any items match the filter.get(int slot) Gets an item at a specific slot index.getAll(int... ids) Gets all items with any of the specified IDs.Gets all items with any of the specified names.Gets all items matching a filter.default intgetCount(boolean stacks, int... ids) Counts items with any of the specified IDs.default intCounts items with any of the specified names.default intCounts items matching a filter.default intgetCount(int... ids) Counts items with any of the specified IDs, including stack quantities.default intCounts items with any of the specified names, including stack quantities.default intCounts items matching a filter, including stack quantities.default TgetFirst(int... ids) Gets the first item with any of the specified IDs.default TGets the first item with any of the specified names.default TGets the first item matching a filter.default TgetLast(int... ids) Gets the last item with any of the specified IDs.default TGets the last item with any of the specified names.default TGets the last item (highest slot index) matching a filter.
-
Method Details
-
getAll
Gets all items matching a filter.- Parameters:
filter- the predicate to test items against- Returns:
- list of matching items (may be empty, never null)
-
getAll
Gets all items with any of the specified IDs.- Parameters:
ids- the item IDs to match- Returns:
- list of matching items (may be empty)
-
getAll
Gets all items with any of the specified names.- Parameters:
names- the item names to match- Returns:
- list of matching items (may be empty)
-
getFirst
Gets the first item matching a filter.- Parameters:
filter- the predicate to test items against- Returns:
- the first matching item, or null if none found
-
getFirst
Gets the first item with any of the specified IDs.- Parameters:
ids- the item IDs to match- Returns:
- the first matching item, or null if none found
-
getFirst
Gets the first item with any of the specified names.- Parameters:
names- the item names to match- Returns:
- the first matching item, or null if none found
-
getLast
Gets the last item (highest slot index) matching a filter.- Parameters:
filter- the predicate to test items against- Returns:
- the last matching item, or null if none found
-
getLast
Gets the last item with any of the specified IDs.- Parameters:
ids- the item IDs to match- Returns:
- the last matching item, or null if none found
-
getLast
Gets the last item with any of the specified names.- Parameters:
names- the item names to match- Returns:
- the last matching item, or null if none found
-
getCount
Counts items matching a filter.- Parameters:
stacks- if true, sum stack quantities; if false, count as 1 eachfilter- the predicate to test items against- Returns:
- the total count
-
getCount
default int getCount(boolean stacks, int... ids) Counts items with any of the specified IDs.- Parameters:
stacks- if true, sum stack quantities; if false, count as 1 eachids- the item IDs to match- Returns:
- the total count
-
getCount
Counts items with any of the specified names.- Parameters:
stacks- if true, sum stack quantities; if false, count as 1 eachnames- the item names to match- Returns:
- the total count
-
getCount
Counts items matching a filter, including stack quantities.- Parameters:
filter- the predicate to test items against- Returns:
- the total count including stacks
-
getCount
default int getCount(int... ids) Counts items with any of the specified IDs, including stack quantities.- Parameters:
ids- the item IDs to match- Returns:
- the total count including stacks
-
getCount
Counts items with any of the specified names, including stack quantities.- Parameters:
names- the item names to match- Returns:
- the total count including stacks
-
contains
Checks if any item matches the filter.- Parameters:
filter- the predicate to test items against- Returns:
- true if at least one item matches
-
contains
default boolean contains(int... ids) Checks if any item has one of the specified IDs.- Parameters:
ids- the item IDs to check for- Returns:
- true if at least one item matches
-
contains
Checks if any item has one of the specified names.- Parameters:
names- the item names to check for- Returns:
- true if at least one item matches
-
containsAll
default boolean containsAll(int... ids) Checks if items exist for ALL of the specified IDs.- Parameters:
ids- the item IDs that must all be present- Returns:
- true if all IDs are found
-
containsAll
Checks if items exist for ALL of the specified names.- Parameters:
names- the item names that must all be present- Returns:
- true if all names are found
-
containsAll
Checks if any items match the filter.Note: This is equivalent to
contains(Predicate).- Parameters:
filter- the predicate to test items against- Returns:
- true if any items match
-
get
Gets an item at a specific slot index.- Parameters:
slot- the slot index- Returns:
- the item at that slot, or null if empty
-