Class Menu

java.lang.Object
de.clickism.clickgui.menu.Menu

public class Menu extends Object
Represents a menu.
  • Field Details

    • player

      protected final org.bukkit.entity.Player player
      The player viewing the menu.
    • size

      protected final int size
      The size of the menu.
    • buttons

      protected final Button[] buttons
      The buttons in the menu.
    • title

      protected String title
      The title of the menu.
    • background

      protected MenuBackground background
      The background of the menu.
    • inventorySupplier

      protected final InventorySupplier inventorySupplier
      The supplier for the inventory.
    • clickHandler

      protected ClickHandler clickHandler
      The click handler for the menu.
    • onOpen

      protected Consumer<MenuView> onOpen
      The action to perform when the menu is open.
    • onClose

      protected Consumer<MenuView> onClose
      The action to perform when the menu is closed.
  • Constructor Details

    • Menu

      public Menu(org.bukkit.entity.Player player, MenuType type)
      Creates a new menu.
      Parameters:
      player - the player viewing the menu
      type - the type of menu
    • Menu

      public Menu(org.bukkit.entity.Player player, org.bukkit.event.inventory.InventoryType inventoryType)
      Creates a new menu.
      Parameters:
      player - the player viewing the menu
      inventoryType - the type of inventory
    • Menu

      protected Menu(org.bukkit.entity.Player player, InventorySupplier inventorySupplier, int size)
      Creates a new menu.
      Parameters:
      player - the player viewing the menu
      inventorySupplier - the supplier for the inventory
      size - the size of the menu
  • Method Details

    • addButton

      public Menu addButton(int slot, Button button)
      Adds a button to the menu.
      Parameters:
      slot - the slot to add the button to
      button - the button to add
      Returns:
      this menu
    • setTitle

      public Menu setTitle(@Colorized String title)
      Sets the title of the menu.
      Parameters:
      title - the title
      Returns:
      this menu
    • setBackground

      public Menu setBackground(MenuBackground background)
      Sets the background of the menu.
      Parameters:
      background - the background
      Returns:
      this menu
    • setClickHandler

      public Menu setClickHandler(ClickHandler clickHandler)
      Sets the click handler of the menu.
      Parameters:
      clickHandler - the click handler
      Returns:
      this menu
    • setOnOpen

      public Menu setOnOpen(Consumer<MenuView> onOpen)
      Sets the action to perform when the menu is opened.
      Parameters:
      onOpen - the action to perform
      Returns:
      this menu
    • setOnClose

      public Menu setOnClose(Consumer<MenuView> onClose)
      Sets the action to perform when the menu is closed.
      Parameters:
      onClose - the action to perform
      Returns:
      this menu
    • getButton

      @Nullable public @Nullable Button getButton(int slot)
      Gets the button at a slot.
      Parameters:
      slot - the slot
      Returns:
      the button
    • open

      public MenuView open(MenuManager menuManager)
      Opens the menu.
      Parameters:
      menuManager - the menu manager
      Returns:
      the view of the menu
    • open

      public MenuView open()
      Opens the menu using the instance of the menu manager set by MenuManager.setInstance(MenuManager).
      Returns:
      the view of the menu
      Throws:
      IllegalStateException - if no instance was set
    • getPlayer

      public org.bukkit.entity.Player getPlayer()
      Gets the player viewing the menu.
      Returns:
      the player