Class ItemContainerSnapshot
java.lang.Object
privbot.hooks.container.ItemContainerSnapshot
Detached item facts, safe to rank on a worker or display on the UI without client access.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classOne occupied slot, by value. -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal booleanFalse means unavailable, not an observed empty container.final List<ItemContainerSnapshot.Item> The occupied slots, in slot order (unmodifiable). -
Constructor Summary
ConstructorsConstructorDescriptionItemContainerSnapshot(List<ItemContainerSnapshot.Item> items, boolean available) -
Method Summary
Modifier and TypeMethodDescriptionintcount(int id) intTotal stack quantity for an exact, case-insensitive name.intcount(Predicate<ItemContainerSnapshot.Item> match) Exact name first, then a case-insensitive substring match.first(Predicate<ItemContainerSnapshot.Item> match) firstWithAction(String action) intfreeSlots(int capacity) booleanbooleanid(int id) names()intsize()slot(int slot) static ItemContainerSnapshot
-
Field Details
-
items
The occupied slots, in slot order (unmodifiable). -
available
public final boolean availableFalse means unavailable, not an observed empty container.
-
-
Constructor Details
-
ItemContainerSnapshot
- Parameters:
items- the occupied slots (copied; no nulls)available- false when the container could not be read
-
-
Method Details
-
size
public int size()- Returns:
- the number of occupied slots (0 also when unavailable: check
available)
-
freeSlots
public int freeSlots(int capacity) - Parameters:
capacity- the container's slot count (28 for the inventory)- Returns:
- free slots; meaningless when unavailable
-
count
public int count(int id) - Parameters:
id- an item id- Returns:
- total quantity with that id
-
count
Total stack quantity for an exact, case-insensitive name. -
count
- Parameters:
match- the test- Returns:
- total quantity of matching slots (saturates at
Integer.MAX_VALUE)
-
slot
- Parameters:
slot- a slot index- Returns:
- the item in it, or null when empty
-
id
- Parameters:
id- an item id- Returns:
- the first slot holding it, or null
-
first
- Parameters:
match- the test- Returns:
- the first matching slot, or null
-
first
Exact name first, then a case-insensitive substring match. Blank names never match. -
firstOf
- Parameters:
names- names in preference order (each: exact first, then substring)- Returns:
- the first slot matching the earliest name that matches, or null
-
has
- Parameters:
name- an item name (exact, then substring)- Returns:
- whether a slot matches
-
hasAny
- Parameters:
names- item names- Returns:
- whether any of them matches a slot
-
firstWithAction
- Parameters:
action- a menu action ("Eat"), case-insensitive- Returns:
- the first slot whose item lists it, or null
-
names