Class MCMenu

java.lang.Object
net.realdarkstudios.commons.menu.MCMenu
Direct Known Subclasses:
PaginationMenu

public abstract class MCMenu extends Object
The base Menu class. This handles the dimensions, title, and slots, as well as opening, closing, and updating the menu.
Since:
0.3.0.0
See Also:
  • Field Details

    • EMPTY_SLOT_ITEM

      public static final MenuItem EMPTY_SLOT_ITEM
      An empty slot item, with a gray stained glass pane and no title
  • Constructor Details

  • Method Details

    • errorItem

      public static MenuItem errorItem(String name)
      Creates an error item, a bedrock item with a custom name
      Parameters:
      name - The name of this item
      Returns:
      The error item
    • getTitleKey

      public LocalizedMessages.Key getTitleKey()
      Gets the title path of this menu
      Returns:
      The title path
    • getName

      public String getName()
      Gets the name of this menu
      Returns:
      The name
    • getSize

      public MCMenu.MenuSize getSize()
      Gets the size of this menu
      Returns:
      The size
    • getSlotCount

      public int getSlotCount()
      Gets the slot count of this menu
      Returns:
      The slot count
    • hasParent

      public boolean hasParent()
      Checks if this menu has a parent
      Returns:
      true if this menu has a parent, false otherwise
    • getParent

      public MCMenu getParent()
      Gets the parent of this menu
      Returns:
      The parent ment
    • setParent

      public void setParent(MCMenu parent)
      Sets the parent of this menu
      Parameters:
      parent - The parent menu
    • setItem

      public MCMenu setItem(@org.checkerframework.common.value.qual.IntRange(from=0L, to=53L) int slot, MenuItem item)
      Sets an item in the specified slot index
      Parameters:
      slot - The index of the slot to set (0-indexed)
      item - The MenuItem to put into this slot
      Returns:
      This menu
    • clearAllSlots

      public MCMenu clearAllSlots()
      Clears all the slots in this menu
      Returns:
      This menu
    • fillEmptySlots

      public MCMenu fillEmptySlots(MenuItem item)
      Fills the empty slots with the specified item
      Parameters:
      item - The MenuItem to fill empty slots with
      Returns:
      This menu
    • fillEmptySlots

      public MCMenu fillEmptySlots()
      Fills the empty slots with EMPTY_SLOT_ITEM
      Returns:
      This menu
    • open

      public void open(org.bukkit.entity.Player player)
      Opens the menu for the given player
      Parameters:
      player - The Player to open this menu for
    • close

      public void close(org.bukkit.entity.Player player)
      Closes the menu for the given player
      Parameters:
      player - The Player to close this menu for
    • update

      public void update(org.bukkit.entity.Player player)
      Updates the menu for the given player
      Parameters:
      player - The Player to update this menu for
    • onInventoryClick

      public void onInventoryClick(org.bukkit.event.inventory.InventoryClickEvent event)
      Called when a slot in the inventory is clicked
      Parameters:
      event - The InventoryClickEvent that was passed
    • delete

      public void delete()
      Deletes this menu
    • coordCheck

      protected boolean coordCheck(org.bukkit.Location loc)
      Checks if the given coordinates is not equal to the default (0, 0, 0)
      Parameters:
      loc - The Location to check
      Returns:
      true if the location is not the default, false otherwise
    • stringCheck

      protected boolean stringCheck(String str)
      Checks if the given string is not null or empty
      Parameters:
      str - The String to check
      Returns:
      true if the string is not null or empty, false otherwise