Class MapleInventory
java.lang.Object
client.inventory.MapleInventory
- All Implemented Interfaces:
Serializable, Iterable<Item>
單一背包分頁(如裝備、消耗、設置、其他、楓點)的記憶體容器。
以格位索引(Short)為鍵的 LinkedHashMap 管理 Item 集合;
持有格位上限(slotLimit,最大 96)、背包類型(MapleInventoryType)
與背包袋道具 ID(bagItem)。
提供新增、移除、依 ID 或格位查詢等操作,並實作 Iterable 供遍歷;
由 client.MapleCharacter 持有,透過 server.MapleInventoryManipulator
完成道具搬移與數量管理。ItemLoader 負責自資料庫填充此容器的初始狀態。
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of MapleInventory -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidshortAdds the item to the inventory and returns the assigned slot idvoidaddSlot(byte slot) intcountById(int itemId) findById(int itemId) Returns the item with its slot id if it exists within the inventory, otherwise null is returnedfindByInventoryId(long itemId, int itemI) findByInventoryIdOnly(long itemId, int itemI) findByUniqueId(int itemId) intfindPostionById(int itemId) getItem(short slot) getItemByInventoryItemId(Long inventoryitemid) shortReturns the next empty slot id, -1 if the inventory is fullshortbytegetType()voidbooleanisFull()booleanisFull(int margin) iterator()list()listById(int itemId) listIds()voidmove(short sSlot, short dSlot, short slotMax) newList()voidvoidremoveItem(short slot) voidremoveItem(short slot, short quantity, boolean allowZero) voidremoveSlot(short slot) voidsetSlotLimit(byte slot) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Constructor Details
-
MapleInventory
Creates a new instance of MapleInventory
-
-
Method Details
-
addSlot
public void addSlot(byte slot) -
getSlotLimit
public byte getSlotLimit() -
setSlotLimit
public void setSlotLimit(byte slot) -
findById
Returns the item with its slot id if it exists within the inventory, otherwise null is returned -
findByUniqueId
-
findByInventoryId
-
findByInventoryIdOnly
-
countById
public int countById(int itemId) -
findPostionById
public int findPostionById(int itemId) -
listById
-
list
-
newList
-
listIds
-
addItem
Adds the item to the inventory and returns the assigned slot id -
addFromDB
-
move
public void move(short sSlot, short dSlot, short slotMax) -
getItem
-
removeItem
public void removeItem(short slot) -
removeItem
public void removeItem(short slot, short quantity, boolean allowZero) -
removeSlot
public void removeSlot(short slot) -
initBagItem
public void initBagItem() -
addBagItem
public void addBagItem() -
removeBagItem
public void removeBagItem() -
isFull
public boolean isFull() -
isFull
public boolean isFull(int margin) -
getNextFreeSlot
public short getNextFreeSlot()Returns the next empty slot id, -1 if the inventory is full -
getNumFreeSlot
public short getNumFreeSlot() -
getType
-
iterator
-
getItemByInventoryItemId
-