Class MapleInventory

java.lang.Object
client.inventory.MapleInventory
All Implemented Interfaces:
Serializable, Iterable<Item>

public class MapleInventory extends Object implements Iterable<Item>, Serializable
單一背包分頁(如裝備、消耗、設置、其他、楓點)的記憶體容器。

以格位索引(Short)為鍵的 LinkedHashMap 管理 Item 集合; 持有格位上限(slotLimit,最大 96)、背包類型(MapleInventoryType) 與背包袋道具 ID(bagItem)。

提供新增、移除、依 ID 或格位查詢等操作,並實作 Iterable 供遍歷; 由 client.MapleCharacter 持有,透過 server.MapleInventoryManipulator 完成道具搬移與數量管理。ItemLoader 負責自資料庫填充此容器的初始狀態。

See Also:
  • Constructor Details

    • MapleInventory

      public MapleInventory(MapleInventoryType type)
      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

      public Item findById(int itemId)
      Returns the item with its slot id if it exists within the inventory, otherwise null is returned
    • findByUniqueId

      public Item findByUniqueId(int itemId)
    • findByInventoryId

      public Item findByInventoryId(long itemId, int itemI)
    • findByInventoryIdOnly

      public Item findByInventoryIdOnly(long itemId, int itemI)
    • countById

      public int countById(int itemId)
    • findPostionById

      public int findPostionById(int itemId)
    • listById

      public List<Item> listById(int itemId)
    • list

      public Collection<Item> list()
    • newList

      public List<Item> newList()
    • listIds

      public List<Integer> listIds()
    • addItem

      public short addItem(Item item)
      Adds the item to the inventory and returns the assigned slot id
    • addFromDB

      public void addFromDB(Item item)
    • move

      public void move(short sSlot, short dSlot, short slotMax)
    • getItem

      public Item getItem(short slot)
    • 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

      public MapleInventoryType getType()
    • iterator

      public Iterator<Item> iterator()
      Specified by:
      iterator in interface Iterable<Item>
    • getItemByInventoryItemId

      public Item getItemByInventoryItemId(Long inventoryitemid)