Class Inventory
java.lang.Object
net.minestom.server.inventory.AbstractInventory
net.minestom.server.inventory.Inventory
- All Implemented Interfaces:
EventHandler<InventoryEvent>, InventoryClickHandler, Taggable, TagReadable, TagWritable, Viewable
- Direct Known Subclasses:
AnvilInventory, BeaconInventory, BrewingStandInventory, EnchantmentTableInventory, FurnaceInventory, VillagerInventory
Represents an inventory which can be viewed by a collection of
Player.
You can create one with Inventory(InventoryType, String) or by making your own subclass.
It can then be opened using Player.openInventory(Inventory).
-
Field Summary
Fields inherited from class AbstractInventory
clickProcessor, itemStacks, unmodifiableViewers, viewers -
Constructor Summary
ConstructorsConstructorDescriptionInventory(InventoryType inventoryType, String title) Inventory(InventoryType inventoryType, Component title) -
Method Summary
Modifier and TypeMethodDescriptionbooleanThis will not open the inventory forplayer, usePlayer.openInventory(Inventory).booleanchangeHeld(Player player, int slot, int key) Called when aPlayerheld click in the inventorybooleandoubleClick(Player player, int slot) Called when aPlayerdouble click in the inventorybooleanbooleanCalled when aPlayerpress the drop buttongetCursorItem(Player player) Deprecated.normal inventories no longer store cursor itemsGets the inventory type.getTitle()Gets the inventory title.byteGets this window id.booleanCalled when aPlayerleft click in the inventory.booleanmiddleClick(Player player, int slot) booleanremoveViewer(Player player) This will not close the inventory forplayer, usePlayer.closeInventory().booleanrightClick(Player player, int slot) Called when aPlayerright click in the inventory.protected voidsendProperty(InventoryProperty property, short value) Sends a window property to all viewers.voidsetCursorItem(Player player, ItemStack cursorItem) Deprecated.normal inventories no longer store cursor itemsvoidChanges the inventory title.booleanshiftClick(Player player, int slot, int button) Called when aPlayershift click in the inventoryMethods inherited from class AbstractInventory
addItemStack, addItemStack, addItemStacks, clear, copyContents, eventNode, getInnerSize, getItemStack, getItemStacks, getSize, getViewers, processItemStack, processItemStacks, replaceItemStack, sendSlotRefresh, setItemStack, setItemStack, tagHandler, takeItemStack, takeItemStacks, UNSAFE_itemInsert, update, 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
-
Constructor Details
-
Inventory
-
Inventory
-
-
Method Details
-
getInventoryType
-
getTitle
-
setTitle
Changes the inventory title.- Parameters:
title- the new inventory title
-
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
-
addViewer
This will not open the inventory forplayer, usePlayer.openInventory(Inventory).- Specified by:
addViewerin interfaceViewable- Overrides:
addViewerin classAbstractInventory- Parameters:
player- the viewer to add- Returns:
- true if the player has successfully been added
-
removeViewer
This will not close the inventory forplayer, usePlayer.closeInventory().- Specified by:
removeViewerin interfaceViewable- Overrides:
removeViewerin classAbstractInventory- Parameters:
player- the viewer to remove- Returns:
- true if the player has successfully been removed
-
getCursorItem
Deprecated.normal inventories no longer store cursor itemsGets the cursor item of a player.- See Also:
-
setCursorItem
Deprecated.normal inventories no longer store cursor itemsChanges the cursor item of a player.- See Also:
-
sendProperty
Sends a window property to all viewers.- Parameters:
property- the property to sendvalue- the value of the property- See Also:
-
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
-
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
-
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
-
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
-