Package net.minestom.server.inventory
Class PlayerInventory
java.lang.Object
net.minestom.server.inventory.AbstractInventory
net.minestom.server.inventory.PlayerInventory
- All Implemented Interfaces:
InventoryClickHandler
,Taggable
,TagReadable
,TagWritable
,Viewable
Represents the inventory of a
Player
, retrieved with Player.getInventory()
.-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
Fields inherited from class net.minestom.server.inventory.AbstractInventory
clickProcessor, inventoryConditions, itemStacks, unmodifiableViewers, viewers
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
changeHeld
(@NotNull Player player, int slot, int key) Called when aPlayer
held click in the inventoryvoid
clear()
Clears the inventory and send relevant update to the viewer(s).boolean
doubleClick
(@NotNull Player player, int slot) Called when aPlayer
double click in the inventoryboolean
boolean
Called when aPlayer
press the drop button@NotNull ItemStack
Gets the item in player cursor.@NotNull ItemStack
getEquipment
(@NotNull EquipmentSlot slot, byte heldSlot) int
Gets the size of the "inner inventory" (which includes only "usable" slots).byte
Gets this window id.boolean
Called when aPlayer
left click in the inventory.boolean
middleClick
(@NotNull Player player, int slot) boolean
rightClick
(@NotNull Player player, int slot) Called when aPlayer
right click in the inventory.void
sendSlotRefresh
(int slot, @NotNull ItemStack item, @NotNull ItemStack previous) void
setCursorItem
(@NotNull ItemStack cursorItem) Changes the player cursor item.void
setEquipment
(@NotNull EquipmentSlot slot, byte heldSlot, @NotNull ItemStack itemStack) boolean
shiftClick
(@NotNull Player player, int slot) Called when aPlayer
shift click in the inventoryprotected void
UNSAFE_itemInsert
(int slot, @NotNull ItemStack item, @NotNull ItemStack previous, boolean sendPacket) void
Refreshes the inventory for a specific viewer.Methods inherited from class net.minestom.server.inventory.AbstractInventory
addInventoryCondition, addItemStack, addItemStack, addItemStacks, addViewer, copyContents, getInventoryConditions, getItemStack, getItemStacks, getSize, getViewers, processItemStack, processItemStacks, removeViewer, replaceItemStack, setItemStack, setItemStack, tagHandler, takeItemStack, takeItemStacks, update
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minestom.server.inventory.InventoryClickHandler
callClickEvent
Methods inherited from interface net.minestom.server.tag.Taggable
getAndSetTag, getAndUpdateTag, getTag, hasTag, removeTag, setTag, updateAndGetTag, updateTag
Methods inherited from interface net.minestom.server.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:AbstractInventory
Clears the inventory and send relevant update to the viewer(s).- Overrides:
clear
in classAbstractInventory
-
getInnerSize
public int getInnerSize()Description copied from class:AbstractInventory
Gets the size of the "inner inventory" (which includes only "usable" slots).- Overrides:
getInnerSize
in classAbstractInventory
- Returns:
- inner inventory's size
-
getWindowId
public byte getWindowId()Description copied from class:AbstractInventory
Gets this window id.This is the id that the client will send to identify the affected inventory, mostly used by packets.
- Specified by:
getWindowId
in classAbstractInventory
- Returns:
- the window id
-
getEquipment
@NotNull public @NotNull ItemStack getEquipment(@NotNull @NotNull EquipmentSlot slot, byte heldSlot) -
setEquipment
public void setEquipment(@NotNull @NotNull EquipmentSlot slot, byte heldSlot, @NotNull @NotNull ItemStack itemStack) -
update
Description copied from class:AbstractInventory
Refreshes the inventory for a specific viewer.- Overrides:
update
in classAbstractInventory
- Parameters:
player
- the player to update the inventory for
-
getCursorItem
Gets the item in player cursor.- Returns:
- the cursor item
-
setCursorItem
Changes the player cursor item.- Parameters:
cursorItem
- the new cursor item
-
UNSAFE_itemInsert
protected void UNSAFE_itemInsert(int slot, @NotNull @NotNull ItemStack item, @NotNull @NotNull ItemStack previous, boolean sendPacket) - Overrides:
UNSAFE_itemInsert
in classAbstractInventory
-
sendSlotRefresh
public void sendSlotRefresh(int slot, @NotNull @NotNull ItemStack item, @NotNull @NotNull ItemStack previous) - Overrides:
sendSlotRefresh
in classAbstractInventory
-
leftClick
Description copied from interface:InventoryClickHandler
Called when aPlayer
left 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:InventoryClickHandler
Called when aPlayer
right 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:InventoryClickHandler
Called when aPlayer
press the drop button- Parameters:
player
- the player who clickedall
-slot
- the slot numberbutton
- -999 if clicking outside, normal if he is not- Returns:
- true if the drop hasn't been cancelled, false otherwise
-
shiftClick
Description copied from interface:InventoryClickHandler
Called when aPlayer
shift click in the inventory- Parameters:
player
- the player who clickedslot
- the slot number- Returns:
- true if the click hasn't been cancelled, false otherwise
-
changeHeld
Description copied from interface:InventoryClickHandler
Called when aPlayer
held 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:InventoryClickHandler
Called when aPlayer
double click in the inventory- Parameters:
player
- the player who clickedslot
- the slot number- Returns:
- true if the click hasn't been cancelled, false otherwise
-