Class InventoryQuery
- java.lang.Object
-
- com.kraken.api.core.AbstractQuery<InventoryEntity,InventoryQuery,ContainerItem>
-
- com.kraken.api.query.container.inventory.InventoryQuery
-
public class InventoryQuery extends AbstractQuery<InventoryEntity,InventoryQuery,ContainerItem>
-
-
Field Summary
-
Fields inherited from class com.kraken.api.core.AbstractQuery
ctx
-
-
Constructor Summary
Constructors Constructor Description InventoryQuery(Context ctx)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InventoryQueryfood()Returns a list of Inventory Items which can be consumed for health.intfreeSpace()Returns the free space in a users inventory.booleanhasFood()Returns true when the player has edible hard food in their inventory and false otherwise.booleanhasItem(int id)Returns true when the inventory contains a specific item, found by its item id.booleanhasItem(java.lang.String name)Returns true when the inventory contains a specific item, found by its name.booleanhasItems(int... ids)Returns true ONLY if the inventory contains ALL of the specified item IDs.booleanhasItems(java.lang.String... names)Returns true ONLY if the inventory contains ALL of the specified item names.booleanhasItems(java.util.List<java.lang.Integer> ids)Determines whether the inventory contains all items specified by the given list of IDs.booleanisEmpty()Returns true if the inventory is empty and false otherwise.booleanisFull()Returns true if the inventory is full and false otherwise.InventoryQuerynoted()Filters for items that are noted (cert).InventoryQueryorderBy(InventoryOrder order)Sorts the inventory query results based on the specifiedInventoryOrder.InventoryQueryquantityGreaterThan(int amount)Filters by item quantity.protected java.util.function.Supplier<java.util.stream.Stream<InventoryEntity>>source()InventoryQuerystackable()Filters for items that stack (runes, arrows, noted items).InventoryQueryunnoted()Filters for un-noted items.InventoryQuerywithAction(java.lang.String action)Filters for inventory items with a specific action like: "Drop", "Eat", or "Examine".
-
-
-
Constructor Detail
-
InventoryQuery
public InventoryQuery(Context ctx)
-
-
Method Detail
-
source
protected java.util.function.Supplier<java.util.stream.Stream<InventoryEntity>> source()
- Specified by:
sourcein classAbstractQuery<InventoryEntity,InventoryQuery,ContainerItem>
-
hasItem
public boolean hasItem(int id)
Returns true when the inventory contains a specific item, found by its item id.- Parameters:
id- The id of the item to search for- Returns:
- True if the inventory has the item and false otherwise
-
hasItem
public boolean hasItem(java.lang.String name)
Returns true when the inventory contains a specific item, found by its name. This is case-insensitive but does require the entire item name.- Parameters:
name- The name of the item to search for- Returns:
- True if the inventory has the item and false otherwise
-
hasItems
public boolean hasItems(int... ids)
Returns true ONLY if the inventory contains ALL of the specified item IDs.- Parameters:
ids- Variable argument of item IDs to search for.- Returns:
- True if every single ID in the arguments exists in the inventory.
-
hasItems
public boolean hasItems(java.util.List<java.lang.Integer> ids)
Determines whether the inventory contains all items specified by the given list of IDs.If the provided list of IDs is
nullor empty, the method returnstrue. Otherwise, it internally converts the list to an array and delegates the check to thehasItems(int... ids)method.- Parameters:
ids- AListofIntegerIDs representing the items to search for. Each ID corresponds to a specific inventory item.- If the list is
nullor empty, the method will returntrue. - All IDs in the list must exist in the inventory for the method to return
true.
- If the list is
- Returns:
trueif the inventory contains all items specified in the list, or if the list isnullor empty. Otherwise,falseis returned.
-
hasItems
public boolean hasItems(java.lang.String... names)
Returns true ONLY if the inventory contains ALL of the specified item names. This is case-insensitive.- Parameters:
names- Variable argument of item names to search for.- Returns:
- True if every single name in the arguments exists in the inventory.
-
orderBy
public InventoryQuery orderBy(InventoryOrder order)
Sorts the inventory query results based on the specifiedInventoryOrder.This method applies the given
InventoryOrder's comparator to sort inventory items based on the desired order or pattern.- Parameters:
order- TheInventoryOrderspecifying the sorting strategy.- @TOP_LEFT_BOTTOM_RIGHT - Standard reading order: Row 1 (Left->Right), Row 2 (Left->Right), etc.
- @BOTTOM_RIGHT_TOP_LEFT - Reverse reading order: Last Item -> First Item.
- @ZIG_ZAG - Snake/Zig-Zag pattern: Row 1 (Left->Right), Row 2 (Right->Left), Row 3 (Left->Right), etc.
- @ZIG_ZAG_REVERSE - Reverse Snake/Zig-Zag pattern starting from the bottom right.
- @TOP_DOWN_LEFT_RIGHT - Vertical columns: Column 1 (Top->Bottom), Column 2 (Top->Bottom), etc.
- Returns:
- An
InventoryQueryobject containing the inventory items sorted based on the given order.
-
withAction
public InventoryQuery withAction(java.lang.String action)
Filters for inventory items with a specific action like: "Drop", "Eat", or "Examine".- Parameters:
action- The action to filter for- Returns:
- InventoryQuery
-
isEmpty
public boolean isEmpty()
Returns true if the inventory is empty and false otherwise.- Returns:
- true if the inventory is empty and false otherwise.
-
isFull
public boolean isFull()
Returns true if the inventory is full and false otherwise.- Returns:
- True if the inventory is full and false otherwise.
-
freeSpace
public int freeSpace()
Returns the free space in a users inventory.- Returns:
- The amount of free space available in the players inventory
-
food
public InventoryQuery food()
Returns a list of Inventory Items which can be consumed for health.- Returns:
- List of Inventory items which are food.
-
hasFood
public boolean hasFood()
Returns true when the player has edible hard food in their inventory and false otherwise.- Returns:
- boolean
-
noted
public InventoryQuery noted()
Filters for items that are noted (cert).- Returns:
- InventoryQuery
-
unnoted
public InventoryQuery unnoted()
Filters for un-noted items.- Returns:
- InventoryQuery
-
stackable
public InventoryQuery stackable()
Filters for items that stack (runes, arrows, noted items).- Returns:
- InventoryQuery
-
quantityGreaterThan
public InventoryQuery quantityGreaterThan(int amount)
Filters by item quantity. This filter is strictly greater than i.ectx.inventory().nameContains("karambwanji").quantityGreaterThan(500);will only return aContainerItemwhen 501 Karambwanji's are present.- Parameters:
amount- The amount of the stack to filter for.- Returns:
- InventoryQuery
-
-