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 Type
    Method
    Description
    default boolean
    contains(int... ids)
    Checks if any item has one of the specified IDs.
    default boolean
    contains(String... names)
    Checks if any item has one of the specified names.
    default boolean
    contains(Predicate<? super T> filter)
    Checks if any item matches the filter.
    default boolean
    containsAll(int... ids)
    Checks if items exist for ALL of the specified IDs.
    default boolean
    containsAll(String... names)
    Checks if items exist for ALL of the specified names.
    default boolean
    containsAll(Predicate<? super T> filter)
    Checks if any items match the filter.
    get(int slot)
    Gets an item at a specific slot index.
    default List<T>
    getAll(int... ids)
    Gets all items with any of the specified IDs.
    default List<T>
    getAll(String... names)
    Gets all items with any of the specified names.
    getAll(Predicate<? super T> filter)
    Gets all items matching a filter.
    default int
    getCount(boolean stacks, int... ids)
    Counts items with any of the specified IDs.
    default int
    getCount(boolean stacks, String... names)
    Counts items with any of the specified names.
    default int
    getCount(boolean stacks, Predicate<? super T> filter)
    Counts items matching a filter.
    default int
    getCount(int... ids)
    Counts items with any of the specified IDs, including stack quantities.
    default int
    getCount(String... names)
    Counts items with any of the specified names, including stack quantities.
    default int
    getCount(Predicate<? super T> filter)
    Counts items matching a filter, including stack quantities.
    default T
    getFirst(int... ids)
    Gets the first item with any of the specified IDs.
    default T
    getFirst(String... names)
    Gets the first item with any of the specified names.
    default T
    getFirst(Predicate<? super T> filter)
    Gets the first item matching a filter.
    default T
    getLast(int... ids)
    Gets the last item with any of the specified IDs.
    default T
    getLast(String... names)
    Gets the last item with any of the specified names.
    default T
    getLast(Predicate<? super T> filter)
    Gets the last item (highest slot index) matching a filter.
  • Method Details

    • getAll

      List<T> getAll(Predicate<? super T> filter)
      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

      default List<T> getAll(int... ids)
      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

      default List<T> getAll(String... names)
      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

      default T getFirst(Predicate<? super T> filter)
      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

      default T getFirst(int... ids)
      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

      default T getFirst(String... names)
      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

      default T getLast(Predicate<? super T> filter)
      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

      default T getLast(int... ids)
      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

      default T getLast(String... names)
      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

      default int getCount(boolean stacks, Predicate<? super T> filter)
      Counts items matching a filter.
      Parameters:
      stacks - if true, sum stack quantities; if false, count as 1 each
      filter - 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 each
      ids - the item IDs to match
      Returns:
      the total count
    • getCount

      default int getCount(boolean stacks, String... names)
      Counts items with any of the specified names.
      Parameters:
      stacks - if true, sum stack quantities; if false, count as 1 each
      names - the item names to match
      Returns:
      the total count
    • getCount

      default int getCount(Predicate<? super T> filter)
      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

      default int getCount(String... names)
      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

      default boolean contains(Predicate<? super T> filter)
      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

      default boolean contains(String... names)
      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

      default boolean containsAll(String... names)
      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

      default boolean containsAll(Predicate<? super T> filter)
      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

      T get(int slot)
      Gets an item at a specific slot index.
      Parameters:
      slot - the slot index
      Returns:
      the item at that slot, or null if empty