Module moe.maple.script.api
Interface InventoryHolderObject<T>
- All Superinterfaces:
ScriptObject<T>
- All Known Subinterfaces:
UserObject<T>
public interface InventoryHolderObject<T> extends ScriptObject<T>
An object that has a single inventory or a collection of inventories.
Typically a user/character.
-
Method Summary
Modifier and Type Method Description default booleanaddItem(int itemTemplateId)Adds a single item into this object's inventory.booleanaddItem(int itemTemplateId, int count)Adds an item into this objects inventory.booleanaddItemAll(int... itemTemplateId)Adds ALL ITEMS in the array.booleanaddItemAll(Collection<Tuple<Integer,Integer>> itemTemplateIdAndCount)default booleanaddItemAll(Tuple<Integer,Integer>... itemTemplateIdAndCount)Add ALL ITEMS in the array with their count.default booleanexchange(int money, int... itemTemplateIdAndCount)default booleanexchange(int money, int itemId, int itemCount)This is an inventory transaction that only applies changes if all actions can be completed.default booleanexchange(int money, List<Tuple<Integer,Integer>> itemTemplateIdAndCount)default booleanexchange(int money, Tuple<Integer,Integer>... itemTemplateIdAndCount)This is an inventory transaction that only applies changes if all actions can be completed.default voidexchange(BasicScriptAction onFalse, int money, int... itemIdAndCount)default voidexchange(BasicScriptAction onFalse, int money, int itemId, int itemCount)default voidexchange(BasicScriptAction onTrue, BasicScriptAction onFalse, int money, int... itemIdAndCount)default voidexchange(BasicScriptAction onTrue, BasicScriptAction onFalse, int money, int itemId, int itemCount)default voidexchange(BasicScriptAction onTrue, BasicScriptAction onFalse, Exchange exchange)default voidexchange(BasicScriptAction onFalse, Exchange exchange)booleanexchange(Exchange exchange)default intgetHoldCount(int inventoryType)Retrieves the # of non-empty slots in an inventory.Optional<InventorySlotObject>getItem(int inventoryType, short slot)default Optional<InventorySlotObject>getItemCash(byte slot)default Optional<InventorySlotObject>getItemConsume(byte slot)intgetItemCount(int itemTemplateId)default Optional<InventorySlotObject>getItemEquip(short slot)default Optional<InventorySlotObject>getItemEtc(byte slot)default Optional<InventorySlotObject>getItemInstall(byte slot)default Collection<InventorySlotObject>getItems(int inventoryType)default Collection<InventorySlotObject>getItemsCash()default Map<Short,InventorySlotObject>getItemsCashMap()default Collection<InventorySlotObject>getItemsConsume()default Map<Short,InventorySlotObject>getItemsConsumeMap()default Collection<InventorySlotObject>getItemsEquip()default Map<Short,InventorySlotObject>getItemsEquipMap()default Collection<InventorySlotObject>getItemsEquipped()default Collection<InventorySlotObject>getItemsEtc()default Map<Short,InventorySlotObject>getItemsEtcMap()default Collection<InventorySlotObject>getItemsInstall()default Map<Short,InventorySlotObject>getItemsInstallMap()default Map<Short,InventorySlotObject>getItemsMap(int inventoryType)intgetSlotCount(int inventoryType)Retrieves the # of accessible slots in an inventory.default booleanhasItem(int itemTemplateId)default booleanhasItem(int itemTemplateId, int count)booleanincreaseSlotCount(int inventoryType, int howMany)Increases the # of usable slots in an inventory tab based on an Inventory Type enumeration.default booleanincreaseSlotCountForCash(int howMany)default booleanincreaseSlotCountForEquip(int howMany)default booleanincreaseSlotCountForEtc(int howMany)default booleanincreaseSlotCountForSetup(int howMany)default booleanincreaseSlotCountForUse(int howMany)booleanremoveItem(int itemTemplateId)Remove ALL INSTANCES where an item matches the item id.booleanremoveItem(int itemTemplateId, int count)Removes an amount of items where the item matches the item id.booleanremoveItemAll(int... itemTemplateId)Remove ALL INSTANCES where an item matches the item id.booleanremoveItemAll(Collection<Tuple<Integer,Integer>> itemTemplateIdAndCount)default booleanremoveItemAll(Tuple<Integer,Integer>... itemTemplateIdAndCount)Removes ALL ITEMS in the array with their count.booleanremoveSlot(int tab, short position)Remove ALL ITEMS at the specified slot position.default booleanremoveSlotCash(short position)default booleanremoveSlotEquip(short position)default booleanremoveSlotEtc(short position)default booleanremoveSlotSetup(short position)default booleanremoveSlotUse(short position)Stream<InventorySlotObject>streamItems(int inventoryType)default Stream<InventorySlotObject>streamItems(int inventoryType, Predicate<InventorySlotObject> filter)default Stream<InventorySlotObject>streamItemsEquipped()
-
Method Details
-
exchange
-
exchange
default boolean exchange(int money, int itemId, int itemCount)This is an inventory transaction that only applies changes if all actions can be completed.- Parameters:
money- - The +/- meso amount to increase/decrease byitemId- - The .wz id of the item to add or removeitemCount- - The +/- amount to increase/decrease by- Returns:
- true if all actions were completed
-
exchange
default void exchange(BasicScriptAction onTrue, BasicScriptAction onFalse, int money, int itemId, int itemCount) -
exchange
-
exchange
-
exchange
-
exchange
This is an inventory transaction that only applies changes if all actions can be completed.- Parameters:
money- - The +/- meso amount to increase/decrease byitemTemplateIdAndCount- - An array of Tuples. Left parameter should be the .wz id of the item. Right parameter should be the amount to add or remove.- Returns:
- true if all actions were completed
-
exchange
-
exchange
default boolean exchange(int money, int... itemTemplateIdAndCount) -
exchange
default void exchange(BasicScriptAction onTrue, BasicScriptAction onFalse, int money, int... itemIdAndCount) -
exchange
-
addItem
boolean addItem(int itemTemplateId, int count)Adds an item into this objects inventory.- Parameters:
itemTemplateId- - The .wz id of the itemcount- - The amount to add.- Returns:
- true if the item and the correct amount were added.
-
addItem
default boolean addItem(int itemTemplateId)Adds a single item into this object's inventory.- Parameters:
itemTemplateId- - The .wz id of the item- Returns:
- true if single item was added
-
addItemAll
boolean addItemAll(int... itemTemplateId)Adds ALL ITEMS in the array. This should ONLY ADD ITEMS IF ALL CAN BE ADDED.- Parameters:
itemTemplateId-- Returns:
- true if ALL ITEMS were added
-
addItemAll
Add ALL ITEMS in the array with their count. This should ONLY ADD ITEMS IF ALL CAN BE ADDED.- Parameters:
itemTemplateIdAndCount- - An array of Tuples. Left parameter should be the .wz id of the item. Right parameter should be the amount to add.- Returns:
- true if ALL ITEMS were added
-
addItemAll
-
removeItem
boolean removeItem(int itemTemplateId)Remove ALL INSTANCES where an item matches the item id.- Parameters:
itemTemplateId- - The .wz id of the item- Returns:
- true if at least one was removed
-
removeItem
boolean removeItem(int itemTemplateId, int count)Removes an amount of items where the item matches the item id. This should ONLY REMOVE AN ITEM if you can remove THE CORRECT AMOUNT.- Parameters:
itemTemplateId- - The .wz id of the itemcount-- Returns:
- true if THE COUNT WAS REMOVED
-
removeItemAll
boolean removeItemAll(int... itemTemplateId)Remove ALL INSTANCES where an item matches the item id. This should ONLY REMOVE AN ITEM IF ALL CAN BE REMOVED.- Parameters:
itemTemplateId- - The .wz id of the item- Returns:
- true if ALL ITEMS WERE REMOVED
-
removeItemAll
Removes ALL ITEMS in the array with their count. This should ONLY ADD ITEMS IF ALL CAN BE REMOVED.- Parameters:
itemTemplateIdAndCount- - An array of Tuples. Left parameter should be the .wz id of the item. Right parameter should be the amount to add.- Returns:
- true if ALL WERE REMOVED
-
removeItemAll
-
removeSlot
boolean removeSlot(int tab, short position)Remove ALL ITEMS at the specified slot position.- Parameters:
tab- An Inventory index as an intposition- AShortslot position- Returns:
- true if the item was removed successfully.
-
removeSlotEquip
default boolean removeSlotEquip(short position) -
removeSlotUse
default boolean removeSlotUse(short position) -
removeSlotSetup
default boolean removeSlotSetup(short position) -
removeSlotEtc
default boolean removeSlotEtc(short position) -
removeSlotCash
default boolean removeSlotCash(short position) -
getItemCount
int getItemCount(int itemTemplateId)- Parameters:
itemTemplateId- - The .wz id of the item- Returns:
- the total count of the itemTemplateId
-
getHoldCount
default int getHoldCount(int inventoryType)Retrieves the # of non-empty slots in an inventory.- Parameters:
inventoryType-- Returns:
- # of filled slots
-
getSlotCount
int getSlotCount(int inventoryType)Retrieves the # of accessible slots in an inventory. (Default is typically 24)- Parameters:
inventoryType-- Returns:
- # of filled slots
-
hasItem
default boolean hasItem(int itemTemplateId, int count)- Returns:
- true if this object holds the total count
-
hasItem
default boolean hasItem(int itemTemplateId) -
increaseSlotCount
boolean increaseSlotCount(int inventoryType, int howMany)Increases the # of usable slots in an inventory tab based on an Inventory Type enumeration. Valid inventory types for incrementation are 1 through 5 (EQUIP, CONSUME, INSTALL, ETC, CASH respectively).- Parameters:
inventoryType- Inventory Type as an integer.howMany- How many slots to add.- Returns:
- true if the operation was successful.
-
increaseSlotCountForEquip
default boolean increaseSlotCountForEquip(int howMany) -
increaseSlotCountForUse
default boolean increaseSlotCountForUse(int howMany) -
increaseSlotCountForSetup
default boolean increaseSlotCountForSetup(int howMany) -
increaseSlotCountForEtc
default boolean increaseSlotCountForEtc(int howMany) -
increaseSlotCountForCash
default boolean increaseSlotCountForCash(int howMany) -
getItems
- Parameters:
inventoryType- Inventory Type as an integer,increaseSlotCount(int, int)- Returns:
- An immutable inventory collection
-
getItem
- Parameters:
inventoryType- Inventory Type as an integer,increaseSlotCount(int, int)slot- the inventory slot position- Returns:
- an item at this slot, if it exists
-
getItemEquip
-
getItemConsume
-
getItemInstall
-
getItemEtc
-
getItemCash
-
getItemsMap
- Parameters:
inventoryType- Inventory Type as an integer,increaseSlotCount(int, int)- Returns:
- an inventory's slot : item map
-
getItemsEquipMap
-
getItemsConsumeMap
-
getItemsInstallMap
-
getItemsEtcMap
-
getItemsCashMap
-
getItemsEquip
-
getItemsConsume
-
getItemsInstall
-
getItemsEtc
-
getItemsCash
-
streamItems
- Parameters:
inventoryType- Inventory Type as an integer,increaseSlotCount(int, int)- Returns:
- A stream of
InventorySlotObject
-
streamItems
default Stream<InventorySlotObject> streamItems(int inventoryType, Predicate<InventorySlotObject> filter) -
streamItemsEquipped
-
getItemsEquipped
-