Class MinestomInventoryUI

java.lang.Object
io.github.projectunified.craftux.minestom.MinestomInventoryUI

public class MinestomInventoryUI extends Object
The inventory UI for Minestom
  • Constructor Summary

    Constructors
    Constructor
    Description
    MinestomInventoryUI(UUID viewerId, net.minestom.server.inventory.Inventory inventory)
    Create a new inventory UI
    MinestomInventoryUI(UUID viewerId, net.minestom.server.inventory.InventoryType inventoryType, net.kyori.adventure.text.Component title)
    Create a new inventory UI
  • Method Summary

    Modifier and Type
    Method
    Description
    protected 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 UI
    net.minestom.server.inventory.Inventory
    Get the inventory
    Get the mask
    Get the viewer's UUID
    protected 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 the inventory for the viewer
    void
    open(net.minestom.server.entity.Player player)
    Open the inventory for the player
    void
    Register the inventory UI event node to the global event handler
    void
    setDefaultButton(Button defaultButton)
    Set the default button.
    void
    setMask(Mask mask)
    Set the mask
    void
    Unregister the inventory UI event node from the global event handler
    void
    Update the inventory

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MinestomInventoryUI

      public MinestomInventoryUI(UUID viewerId, net.minestom.server.inventory.Inventory inventory)
      Create a new inventory UI
      Parameters:
      viewerId - the viewer's UUID
      inventory - 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 UUID
      inventoryType - the inventory type
      title - 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

      public UUID getViewerId()
      Get the viewer's UUID
      Returns:
      the viewer's UUID
    • getMask

      public Mask getMask()
      Get the mask
      Returns:
      the mask
    • setMask

      public void setMask(Mask mask)
      Set the mask
      Parameters:
      mask - the mask
    • getDefaultButton

      public Button getDefaultButton()
      Get the default button. This button is used when an item is not explicitly defined in the mask.
      Returns:
      the default button
    • setDefaultButton

      public void setDefaultButton(Button defaultButton)
      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

      protected ActionItem 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