Package com.valhalla.sdk.api.methods
Class Inventory
java.lang.Object
com.valhalla.sdk.api.methods.Inventory
Inventory-container queries and capability-backed item actions.
Check Client.supports(String) with Capabilities.INVENTORY before
depending on inventory state. Query methods operate on immutable Item
snapshots. Action methods return whether native dispatch was accepted, not whether
the server applied the action; confirm the expected inventory change in a later loop.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intNumber of slots in the standard player inventory. -
Method Summary
Modifier and TypeMethodDescriptionall()Returns all occupied inventory slots.static intcapacity()Returns standard inventory capacity.static booleancontains(int id) Tests whether an identifier exists.static booleancontains(int... ids) Tests whether any identifier exists.static booleanTests whether any item matches a filter.static booleanTests whether any boxed identifier exists.static booleanTests whether an exact name exists.static booleanTests whether any exact name exists.static booleancontainsAll(int... ids) Requires every supplied identifier to appear at least once.static booleancontainsAll(String... names) Requires every supplied exact name to appear at least once.static booleancontainsAll(Collection<?> values) Requires each item, number, or string in a heterogeneous collection to be present.static intcount(int id) Counts stack amounts for one identifier.static intCounts stack amounts accepted by a filter.static intCounts stack amounts for one exact case-insensitive name.static booleanExecutes the second item operation, conventionally Drop for ordinary inventory items.static intCounts vacant inventory slots.Selects items rejected by a filter.static intCounts full inventory slots.get(int id) Finds the first item with an identifier.get(int... ids) Finds the first item matching any primitive identifier.Finds the first item accepted by a filter.Finds the first item matching any boxed non-null identifier.Finds the first item whose full name equals a value, ignoring case.Finds the first item whose full name equals any value, ignoring case.getAt(int slot) Finds the item occupying a zero-based slot.static intCounts vacant inventory slots.static intFinds the first empty slot.static intFinds the first occupied slot.static intgetIdForSlot(int slot) Returns an occupied slot's identifier.getItemInSlot(int slot) Alias forgetAt(int).static StringgetNameForSlot(int slot) Returns an occupied slot's name.getRandom(int... ids) Selects a random item matching any identifier.Selects a uniformly random item accepted by a filter.Selects a random item matching any exact name, ignoring case.static booleaninteract(int id) Dispatches the default operation for the first item with an identifier.static booleanDispatches the default operation for an item's current slot.static booleanDispatches the default operation for the first filtered item.static booleanDispatches the default operation for the first exact-name match.static booleaninteractSlot(int slot) Dispatches the default operation for a valid inventory slot.static booleanisEmpty()Reports whether the inventory is empty.static booleanisFull()Reports whether the inventory is full.static booleanisLoaded()Reports whether the active adapter advertises inventory snapshots.static booleanisSlotEmpty(int slot) Tests whether a valid slot is vacant.static booleanisSlotFull(int slot) Tests whether a valid slot is occupied.Selects every item accepted by a filter.static intCounts occupied inventory slots.static booleanonlyContains(int... ids) Tests whether a non-empty inventory contains only allowed identifiers.static booleanonlyContains(Filter<Item> filter) Tests whether every item in a non-empty inventory satisfies a filter.static booleanonlyContains(String... names) Tests whether a non-empty inventory contains only allowed names.static booleanopen()Opens the inventory tab.static intsize()Returns inventory size by occupied slots.static intslot(int id) Finds the first slot matching an identifier.static intFinds the first slot accepted by a filter.static intFinds the first slot matching a name.static booleanslotContains(int slot, int... ids) Tests whether a slot contains any candidate identifier.static booleanslotContains(int slot, Item item) Compares a slot to an item by definition identifier.static booleanslotContains(int slot, Filter<Item> filter) Tests an occupied slot with a predicate.static booleanslotContains(int slot, String... names) Tests whether a slot contains any exact name, ignoring case.static booleanslotInteract(int slot) Alias forinteractSlot(int).static booleanslotNameContains(int slot, String substring) Tests whether a slot's name contains text, ignoring case.static Item[]toArray()Copies inventory snapshots into an array.static booleanuse(int id) Compatibility alias forinteract(int).static booleanCompatibility alias forinteract(Item).static booleanCompatibility alias forinteract(String).
-
Field Details
-
CAPACITY
public static final int CAPACITYNumber of slots in the standard player inventory.- See Also:
-
-
Method Details
-
capacity
public static int capacity()Returns standard inventory capacity.- Returns:
- standard inventory capacity of 28 slots
-
all
Returns all occupied inventory slots.- Returns:
- inventory item snapshots in native container order
-
matching
Selects every item accepted by a filter.- Parameters:
filter- item predicate- Returns:
- matching snapshots in container order
-
get
Finds the first item with an identifier.- Parameters:
id- item definition identifier- Returns:
- first matching snapshot, or empty
-
get
Finds the first item matching any primitive identifier.- Parameters:
ids- candidate item identifiers- Returns:
- first matching snapshot, or empty for no candidates or no match
-
get
Finds the first item matching any boxed non-null identifier.- Parameters:
ids- candidate item identifiers- Returns:
- first matching snapshot, or empty for no candidates or no match
-
get
Finds the first item whose full name equals a value, ignoring case.- Parameters:
name- exact item name- Returns:
- first matching snapshot, or empty
-
get
Finds the first item whose full name equals any value, ignoring case.- Parameters:
names- exact candidate names- Returns:
- first matching snapshot, or empty
-
get
Finds the first item accepted by a filter.- Parameters:
filter- item predicate- Returns:
- first matching snapshot, or empty
-
getAt
Finds the item occupying a zero-based slot.- Parameters:
slot- inventory slot- Returns:
- item snapshot, or empty when the slot is vacant or out of range
-
getItemInSlot
Alias forgetAt(int).- Parameters:
slot- inventory slot- Returns:
- item snapshot, or empty
-
contains
public static boolean contains(int id) Tests whether an identifier exists.- Parameters:
id- item identifier- Returns:
- whether at least one matching item exists
-
contains
public static boolean contains(int... ids) Tests whether any identifier exists.- Parameters:
ids- candidate identifiers- Returns:
- whether at least one candidate exists
-
contains
Tests whether any boxed identifier exists.- Parameters:
ids- candidate boxed identifiers- Returns:
- whether at least one candidate exists
-
contains
Tests whether an exact name exists.- Parameters:
name- exact case-insensitive name- Returns:
- whether a matching item exists
-
contains
Tests whether any exact name exists.- Parameters:
names- exact candidate names- Returns:
- whether at least one candidate exists
-
contains
Tests whether any item matches a filter.- Parameters:
filter- item predicate- Returns:
- whether at least one item is accepted
-
count
public static int count(int id) Counts stack amounts for one identifier.- Parameters:
id- item identifier- Returns:
- sum of matching stack amounts
-
count
Counts stack amounts for one exact case-insensitive name.- Parameters:
name- exact item name- Returns:
- sum of matching stack amounts, or zero for
null
-
count
Counts stack amounts accepted by a filter.- Parameters:
filter- item predicate- Returns:
- sum of matching stack amounts
-
occupiedSlots
public static int occupiedSlots()Counts occupied inventory slots.- Returns:
- number of occupied inventory slots, independent of stack amounts
-
fullSlotCount
public static int fullSlotCount()Counts full inventory slots.- Returns:
- number of occupied inventory slots; alias for
occupiedSlots()
-
emptySlotCount
public static int emptySlotCount()Counts vacant inventory slots.- Returns:
- number of vacant slots from zero through
CAPACITY
-
getEmptySlots
public static int getEmptySlots()Counts vacant inventory slots.- Returns:
- number of vacant slots; alias for
emptySlotCount()
-
isEmpty
public static boolean isEmpty()Reports whether the inventory is empty.- Returns:
- whether no inventory item snapshots are present
-
isFull
public static boolean isFull()Reports whether the inventory is full.- Returns:
- whether all 28 inventory slots are occupied
-
size
public static int size()Returns inventory size by occupied slots.- Returns:
- number of occupied slots; alias for
occupiedSlots()
-
getFirstEmptySlot
public static int getFirstEmptySlot()Finds the first empty slot.- Returns:
- lowest vacant slot index, or
-1when full
-
getFirstFullSlot
public static int getFirstFullSlot()Finds the first occupied slot.- Returns:
- lowest occupied slot index, or
-1when empty
-
slot
public static int slot(int id) Finds the first slot matching an identifier.- Parameters:
id- item identifier- Returns:
- first matching slot, or
-1
-
slot
Finds the first slot matching a name.- Parameters:
name- exact case-insensitive name- Returns:
- first matching slot, or
-1
-
slot
Finds the first slot accepted by a filter.- Parameters:
filter- item predicate- Returns:
- first matching slot, or
-1
-
getIdForSlot
public static int getIdForSlot(int slot) Returns an occupied slot's identifier.- Parameters:
slot- inventory slot- Returns:
- item identifier, or
-1when vacant
-
getNameForSlot
Returns an occupied slot's name.- Parameters:
slot- inventory slot- Returns:
- item name, or an empty string when vacant
-
slotContains
public static boolean slotContains(int slot, int... ids) Tests whether a slot contains any candidate identifier.- Parameters:
slot- inventory slotids- candidate identifiers- Returns:
truewhen the occupied slot matches one candidate
-
slotContains
Tests whether a slot contains any exact name, ignoring case.- Parameters:
slot- inventory slotnames- candidate names- Returns:
truewhen the occupied slot matches one candidate
-
containsAll
public static boolean containsAll(int... ids) Requires every supplied identifier to appear at least once.- Parameters:
ids- required identifiers- Returns:
truewhen every identifier is present;falsefornull
-
containsAll
Requires every supplied exact name to appear at least once.- Parameters:
names- required case-insensitive names- Returns:
truewhen every name is present;falsefornull
-
containsAll
Requires each item, number, or string in a heterogeneous collection to be present. -
onlyContains
public static boolean onlyContains(int... ids) Tests whether a non-empty inventory contains only allowed identifiers.- Parameters:
ids- allowed identifiers- Returns:
truewhen every item is allowed;falsefor null or empty inventory
-
onlyContains
Tests whether every item in a non-empty inventory satisfies a filter.- Parameters:
filter- allowed-item predicate- Returns:
truewhen every item is accepted and the inventory is non-empty
-
onlyContains
Tests whether a non-empty inventory contains only allowed names.- Parameters:
names- allowed exact case-insensitive names- Returns:
truewhen every item is allowed;falsefor null or empty inventory
-
except
Selects items rejected by a filter.- Parameters:
filter- exclusion predicate- Returns:
- snapshots for which the predicate returned
false
-
toArray
Copies inventory snapshots into an array.- Returns:
- inventory snapshots as a newly allocated array
-
isSlotEmpty
public static boolean isSlotEmpty(int slot) Tests whether a valid slot is vacant.- Parameters:
slot- inventory slot- Returns:
trueonly for a valid vacant slot
-
isSlotFull
public static boolean isSlotFull(int slot) Tests whether a valid slot is occupied.- Parameters:
slot- inventory slot- Returns:
trueonly for a valid occupied slot
-
slotContains
Tests an occupied slot with a predicate.- Parameters:
slot- inventory slotfilter- item predicate- Returns:
truewhen the slot is occupied and accepted
-
slotContains
Compares a slot to an item by definition identifier.- Parameters:
slot- inventory slotitem- comparison item- Returns:
truewhen the occupied slot has the same identifier
-
slotNameContains
Tests whether a slot's name contains text, ignoring case.- Parameters:
slot- inventory slotsubstring- name fragment- Returns:
truewhen an occupied slot's name contains the fragment
-
getRandom
Selects a uniformly random item accepted by a filter.- Parameters:
filter- item predicate- Returns:
- random matching snapshot, or empty
-
getRandom
Selects a random item matching any identifier.- Parameters:
ids- candidate identifiers- Returns:
- random matching snapshot, or empty
-
getRandom
Selects a random item matching any exact name, ignoring case.- Parameters:
names- candidate names- Returns:
- random matching snapshot, or empty
-
interactSlot
public static boolean interactSlot(int slot) Dispatches the default operation for a valid inventory slot.- Parameters:
slot- zero-based inventory slot- Returns:
truewhen the capability is available and dispatch was accepted
-
slotInteract
public static boolean slotInteract(int slot) Alias forinteractSlot(int).- Parameters:
slot- zero-based inventory slot- Returns:
truewhen dispatch was accepted
-
interact
Dispatches the default operation for an item's current slot.- Parameters:
item- current inventory snapshot- Returns:
truewhen dispatch was accepted
-
interact
public static boolean interact(int id) Dispatches the default operation for the first item with an identifier.- Parameters:
id- item identifier- Returns:
truewhen a matching item existed and dispatch was accepted
-
interact
Dispatches the default operation for the first exact-name match.- Parameters:
name- exact case-insensitive name- Returns:
truewhen a matching item existed and dispatch was accepted
-
interact
Dispatches the default operation for the first filtered item.- Parameters:
filter- item predicate- Returns:
truewhen a matching item existed and dispatch was accepted
-
use
Compatibility alias forinteract(Item).- Parameters:
item- current inventory snapshot- Returns:
truewhen dispatch was accepted
-
use
public static boolean use(int id) Compatibility alias forinteract(int).- Parameters:
id- item identifier- Returns:
truewhen dispatch was accepted
-
use
Compatibility alias forinteract(String).- Parameters:
name- exact case-insensitive name- Returns:
truewhen dispatch was accepted
-
drop
Executes the second item operation, conventionally Drop for ordinary inventory items.- Parameters:
item- current inventory snapshot- Returns:
truewhen dispatch was accepted; verify removal separately
-
open
public static boolean open()Opens the inventory tab.- Returns:
truewhen opening the inventory tab was accepted
-
isLoaded
public static boolean isLoaded()Reports whether the active adapter advertises inventory snapshots.- Returns:
truewhenCapabilities.INVENTORYis available
-