Class PlayerInventory
java.lang.Object
net.minestom.server.inventory.AbstractInventory
net.minestom.server.inventory.PlayerInventory
- All Implemented Interfaces:
EventHandler<InventoryEvent>, InventoryClickHandler, Taggable, TagReadable, TagWritable, Viewable
Represents the inventory of a
Player, retrieved with Player.getInventory().-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intFields inherited from class AbstractInventory
clickProcessor, itemStacks, unmodifiableViewers, viewers -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanchangeHeld(Player player, int slot, int key) Called when aPlayerheld click in the inventoryvoidclear()Clears the inventory and send relevant update to the viewer(s).booleandoubleClick(Player player, int slot) Called when aPlayerdouble click in the inventorybooleanbooleanCalled when aPlayerpress the drop buttonGets the item in player cursor.getEquipment(EquipmentSlot slot, byte heldSlot) intGets the size of the "inner inventory" (which includes only "usable" slots).byteGets this window id.booleanCalled when aPlayerleft click in the inventory.booleanmiddleClick(Player player, int slot) booleanrightClick(Player player, int slot) Called when aPlayerright click in the inventory.voidsendSlotRefresh(int slot, ItemStack item) voidsetCursorItem(ItemStack cursorItem) Changes the player cursor item.voidsetCursorItem(ItemStack cursorItem, boolean sendPacket) Changes the player cursor item.voidsetEquipment(EquipmentSlot slot, byte heldSlot, ItemStack itemStack) booleanshiftClick(Player player, int slot, int button) Called when aPlayershift click in the inventoryprotected voidUNSAFE_itemInsert(int slot, ItemStack item, ItemStack previous, boolean sendPacket) voidRefreshes the inventory for a specific viewer.Methods inherited from class AbstractInventory
addItemStack, addItemStack, addItemStacks, addViewer, copyContents, eventNode, getItemStack, getItemStacks, getSize, getViewers, processItemStack, processItemStacks, removeViewer, replaceItemStack, setItemStack, setItemStack, tagHandler, takeItemStack, takeItemStacks, updateMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface InventoryClickHandler
callClickEvent, handleClickMethods inherited from interface Taggable
getAndSetTag, getAndUpdateTag, getTag, hasTag, removeTag, setTag, updateAndGetTag, updateTagMethods inherited from interface Viewable
getViewersAsAudience, getViewersAsAudiences, isViewer, sendPacketsToViewers, sendPacketsToViewers, sendPacketToViewers, sendPacketToViewersAndSelf
-
Field Details
-
INVENTORY_SIZE
public static final int INVENTORY_SIZE- See Also:
-
INNER_INVENTORY_SIZE
public static final int INNER_INVENTORY_SIZE- See Also:
-
-
Constructor Details
-
PlayerInventory
public PlayerInventory()
-
-
Method Details
-
clear
public void clear()Description copied from class:AbstractInventoryClears the inventory and send relevant update to the viewer(s).- Overrides:
clearin classAbstractInventory
-
getInnerSize
public int getInnerSize()Description copied from class:AbstractInventoryGets the size of the "inner inventory" (which includes only "usable" slots).- Overrides:
getInnerSizein classAbstractInventory- Returns:
- inner inventory's size
-
getWindowId
public byte getWindowId()Description copied from class:AbstractInventoryGets this window id.This is the id that the client will send to identify the affected inventory, mostly used by packets.
- Specified by:
getWindowIdin classAbstractInventory- Returns:
- the window id
-
getEquipment
-
setEquipment
-
update
Description copied from class:AbstractInventoryRefreshes the inventory for a specific viewer.- Overrides:
updatein classAbstractInventory- Parameters:
player- the player to update the inventory for
-
getCursorItem
-
setCursorItem
Changes the player cursor item.- Parameters:
cursorItem- the new cursor item
-
setCursorItem
Changes the player cursor item.- Parameters:
cursorItem- the new cursor itemsendPacket- true to send the update packet to the client, false otherwise
-
UNSAFE_itemInsert
- Overrides:
UNSAFE_itemInsertin classAbstractInventory
-
sendSlotRefresh
- Overrides:
sendSlotRefreshin classAbstractInventory
-
leftClick
Description copied from interface:InventoryClickHandlerCalled when aPlayerleft click in the inventory. Can also be to drop the cursor item- Parameters:
player- the player who clickedslot- the slot number- Returns:
- true if the click hasn't been cancelled, false otherwise
-
rightClick
Description copied from interface:InventoryClickHandlerCalled when aPlayerright click in the inventory. Can also be to drop the cursor item- Parameters:
player- the player who clickedslot- the slot number- Returns:
- true if the click hasn't been cancelled, false otherwise
-
middleClick
-
drop
Description copied from interface:InventoryClickHandlerCalled when aPlayerpress the drop button- Parameters:
player- the player who clickedall-slot- the slot number (-999 if clicking outside, i.e. dropping cursor)- Returns:
- true if the drop hasn't been cancelled, false otherwise
-
shiftClick
Description copied from interface:InventoryClickHandlerCalled when aPlayershift click in the inventory- Parameters:
player- the player who clickedslot- the slot numberbutton- the button (same behaviour in vanilla, but can be used for custom behaviour)- Returns:
- true if the click hasn't been cancelled, false otherwise
-
changeHeld
Description copied from interface:InventoryClickHandlerCalled when aPlayerheld click in the inventory- Parameters:
player- the player who clickedslot- the slot numberkey- the held slot (0-8) pressed- Returns:
- true if the click hasn't been cancelled, false otherwise
-
dragging
-
doubleClick
Description copied from interface:InventoryClickHandlerCalled when aPlayerdouble click in the inventory- Parameters:
player- the player who clickedslot- the slot number- Returns:
- true if the click hasn't been cancelled, false otherwise
-