Class Menu

java.lang.Object
dev.demeng.pluginbase.menu.layout.Menu
All Implemented Interfaces:
IMenu

public abstract class Menu extends Object implements IMenu
A GUI menu (custom inventory) that will be displayed to a player.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Menu(int size, @NotNull String title)
    Creates a new menu with the specified size and inventory title.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addButton(int slot, @NotNull org.bukkit.inventory.ItemStack stack, @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> actions)
    Creates and adds a new button to the menu.
    void
    addButton(@NotNull org.bukkit.inventory.ItemStack stack, @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> actions)
    Creates and adds a new button to the menu.
    void
    addButton(@Nullable MenuButton button)
    Adds a new button to the menu.
    void
    applyFillersFromConfig(@NotNull org.bukkit.configuration.ConfigurationSection section)
    Applies all menu fillers that are declared in a configuration section.
    void
    applyFillersFromConfig(@NotNull org.bukkit.configuration.ConfigurationSection section, @Nullable UnaryOperator<String> translator)
    Applies all menu fillers that are declared in a configuration section.
    @NotNull Map<Integer,Consumer<org.bukkit.event.inventory.InventoryClickEvent>>
     
    void
    open(org.bukkit.entity.Player... players)
    Opens the menu for the provided player(s).
    void
    setBackground(@Nullable org.bukkit.inventory.ItemStack stack)
    Applies a background filler, which sets all empty slots in the menu with the dummy button.
    void
    setBorder(@Nullable org.bukkit.inventory.ItemStack stack)
    Applies a border filler, which sets all empty slots on the edges of the menu with a dummy button.
    void
    setColumn(int column, @Nullable org.bukkit.inventory.ItemStack stack)
    Applies a column filler, which sets all empty slots in a column with the dummy button.
    void
    setRow(int row, @Nullable org.bukkit.inventory.ItemStack stack)
    Applies a row filler, which sets all empty slots in a row with the dummy button.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface dev.demeng.pluginbase.menu.IMenu

    onClose
  • Constructor Details

    • Menu

      protected Menu(int size, @NotNull @NotNull String title)
      Creates a new menu with the specified size and inventory title.
      Parameters:
      size - The size of the menu, in slots; must be greater than or equal to 9 and less than or equal to 54, and a multiple of 9
      title - The menu title, colorized internally
  • Method Details

    • getActions

      @NotNull public @NotNull Map<Integer,Consumer<org.bukkit.event.inventory.InventoryClickEvent>> getActions()
    • addButton

      public void addButton(@Nullable @Nullable MenuButton button)
      Adds a new button to the menu.
      Parameters:
      button - The button to add
    • addButton

      public void addButton(int slot, @NotNull @NotNull org.bukkit.inventory.ItemStack stack, @Nullable @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> actions)
      Creates and adds a new button to the menu.
      Parameters:
      slot - The slot of the button
      stack - The stack of the button
      actions - The actions of the button
    • addButton

      public void addButton(@NotNull @NotNull org.bukkit.inventory.ItemStack stack, @Nullable @Nullable Consumer<org.bukkit.event.inventory.InventoryClickEvent> actions)
      Creates and adds a new button to the menu. The first empty slot will be used.
      Parameters:
      stack - The stack of the button
      actions - The actions of the button
    • setBackground

      public void setBackground(@Nullable @Nullable org.bukkit.inventory.ItemStack stack)
      Applies a background filler, which sets all empty slots in the menu with the dummy button.
      Parameters:
      stack - The background material
    • setRow

      public void setRow(int row, @Nullable @Nullable org.bukkit.inventory.ItemStack stack)
      Applies a row filler, which sets all empty slots in a row with the dummy button.
      Parameters:
      row - The row to fill (top to bottom)
      stack - The fill material
    • setColumn

      public void setColumn(int column, @Nullable @Nullable org.bukkit.inventory.ItemStack stack)
      Applies a column filler, which sets all empty slots in a column with the dummy button.
      Parameters:
      column - The column to fill (left to right)
      stack - The fill material
    • setBorder

      public void setBorder(@Nullable @Nullable org.bukkit.inventory.ItemStack stack)
      Applies a border filler, which sets all empty slots on the edges of the menu with a dummy button.
      Parameters:
      stack - The fill material
    • applyFillersFromConfig

      public void applyFillersFromConfig(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection section)
      Applies all menu fillers that are declared in a configuration section.
      Parameters:
      section - The configuration containing the fillers to set
    • applyFillersFromConfig

      public void applyFillersFromConfig(@NotNull @NotNull org.bukkit.configuration.ConfigurationSection section, @Nullable @Nullable UnaryOperator<String> translator)
      Applies all menu fillers that are declared in a configuration section.
      Parameters:
      section - The configuration containing the fillers to set
      translator - The translator for strings in the item
    • open

      public void open(org.bukkit.entity.Player... players)
      Description copied from interface: IMenu
      Opens the menu for the provided player(s).
      Specified by:
      open in interface IMenu
      Parameters:
      players - The players the menu should be opened to