Class MinestomInventoryUI
java.lang.Object
io.github.projectunified.craftux.minestom.MinestomInventoryUI
The inventory UI for Minestom
-
Constructor Summary
ConstructorsConstructorDescriptionMinestomInventoryUI
(UUID viewerId, net.minestom.server.inventory.Inventory inventory) Create a new inventory UIMinestomInventoryUI
(UUID viewerId, net.minestom.server.inventory.InventoryType inventoryType, net.kyori.adventure.text.Component title) Create a new inventory UI -
Method Summary
Modifier and TypeMethodDescriptionprotected ActionItem
Create an action item.Get the default button.net.minestom.server.event.EventNode
<@NotNull net.minestom.server.event.trait.InventoryEvent> Get the event node of the inventory UInet.minestom.server.inventory.Inventory
Get the inventorygetMask()
Get the maskGet the viewer's UUIDprotected void
onClick
(net.minestom.server.event.inventory.InventoryPreClickEvent event) Called when the inventory is clicked.protected void
onClose
(net.minestom.server.event.inventory.InventoryCloseEvent event) Called when the inventory is closed.protected void
onOpen
(net.minestom.server.event.inventory.InventoryOpenEvent event) Called when the inventory is opened.void
open()
Open the inventory for the viewervoid
open
(net.minestom.server.entity.Player player) Open the inventory for the playervoid
register()
Register the inventory UI event node to the global event handlervoid
setDefaultButton
(Button defaultButton) Set the default button.void
Set the maskvoid
Unregister the inventory UI event node from the global event handlervoid
update()
Update the inventory
-
Constructor Details
-
MinestomInventoryUI
Create a new inventory UI- Parameters:
viewerId
- the viewer's UUIDinventory
- the inventory
-
MinestomInventoryUI
public MinestomInventoryUI(UUID viewerId, net.minestom.server.inventory.InventoryType inventoryType, net.kyori.adventure.text.Component title) Create a new inventory UI- Parameters:
viewerId
- the viewer's UUIDinventoryType
- the inventory typetitle
- the title of the inventory
-
-
Method Details
-
register
public void register()Register the inventory UI event node to the global event handler -
unregister
public void unregister()Unregister the inventory UI event node from the global event handler -
getInventory
public net.minestom.server.inventory.Inventory getInventory()Get the inventory- Returns:
- the inventory
-
getEventNode
public net.minestom.server.event.EventNode<@NotNull net.minestom.server.event.trait.InventoryEvent> getEventNode()Get the event node of the inventory UI- Returns:
- the event node
-
open
public void open(net.minestom.server.entity.Player player) Open the inventory for the player- Parameters:
player
- the player
-
open
public void open()Open the inventory for the viewer -
getViewerId
Get the viewer's UUID- Returns:
- the viewer's UUID
-
getMask
Get the mask- Returns:
- the mask
-
setMask
Set the mask- Parameters:
mask
- the mask
-
getDefaultButton
Get the default button. This button is used when an item is not explicitly defined in the mask.- Returns:
- the default button
-
setDefaultButton
Set the default button. This button is used when an item is not explicitly defined in the mask.- Parameters:
defaultButton
- the default button
-
update
public void update()Update the inventory -
createActionItem
Create an action item. Override this to add default logic to the item.- Returns:
- the action item
-
onOpen
protected void onOpen(net.minestom.server.event.inventory.InventoryOpenEvent event) Called when the inventory is opened. Override to add custom behavior.- Parameters:
event
- the event
-
onClick
protected void onClick(net.minestom.server.event.inventory.InventoryPreClickEvent event) Called when the inventory is clicked. Override to add custom behavior.- Parameters:
event
- the event
-
onClose
protected void onClose(net.minestom.server.event.inventory.InventoryCloseEvent event) Called when the inventory is closed. Override to add custom behavior.- Parameters:
event
- the event
-