Class Menu

java.lang.Object
me.efekos.simpler.menu.Menu
All Implemented Interfaces:
org.bukkit.inventory.InventoryHolder
Direct Known Subclasses:
PaginatedMenu

public abstract class Menu extends Object implements org.bukkit.inventory.InventoryHolder
Represents a custom menu. Extend this class to make your custom menus.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected MenuData
    Temporarily data about the owner.
    protected org.bukkit.inventory.Inventory
    Current inventory that is being used by this holder.
    protected org.bukkit.entity.Player
    Player who interacted with this menu.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Menu(MenuData data)
    Crates an instance of this menu.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Closes this menu and open the last menu player visited before this one.
    abstract boolean
    Returns a boolean that indicates click cancels for this menu.
    protected org.bukkit.inventory.ItemStack
    createItem(org.bukkit.Material material, String displayName, String... lore)
    Quickly crates an ItemStack according to the parameters.
    protected org.bukkit.inventory.ItemStack
    createSkull(org.bukkit.entity.Player owner, String displayName, String... lore)
    Quickly creates a skull owned by Player given.
    abstract void
    Main method to set menu items.
    protected void
    fillEmptyWith(org.bukkit.inventory.ItemStack tem)
    Fills all the empty slots with the ItemStack given.
    @NotNull org.bukkit.inventory.Inventory
    Get the object's inventory.
    abstract int
    Returns a row amount for this menu.
    int
    Returns the real slot amount of this menu, which is getRows()*9.
    abstract String
    Returns a title for this menu.
    abstract void
    onClick(org.bukkit.event.inventory.InventoryClickEvent event)
    Executes when someone clicks to an item in this menu.
    abstract void
    onClose(org.bukkit.event.inventory.InventoryCloseEvent event)
    Executes when someone closes this menu.
    abstract void
    onOpen(org.bukkit.event.inventory.InventoryOpenEvent event)
    Executes when someone opens this menu.
    void
    Creates an inventory for this menu and shows it to the owner.
    protected void
    Refreshes the menu items.

    Methods inherited from class java.lang.Object

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

    • inventory

      protected org.bukkit.inventory.Inventory inventory
      Current inventory that is being used by this holder.
    • owner

      protected org.bukkit.entity.Player owner
      Player who interacted with this menu.
    • data

      protected MenuData data
      Temporarily data about the owner. You can store something about this Player to use it in another menu.
  • Constructor Details

  • Method Details

    • cancelAllClicks

      public abstract boolean cancelAllClicks()
      Returns a boolean that indicates click cancels for this menu.
      Returns:
      Should all the clicks at this menu get cancelled?
    • getRows

      public abstract int getRows()
      Returns a row amount for this menu.
      Returns:
      How many rows this menu will have. Your menu will have getRows()*9 slots, since every row makes 9 slot.
    • getTitle

      public abstract String getTitle()
      Returns a title for this menu.
      Returns:
      A title for this menu.
    • onClick

      public abstract void onClick(org.bukkit.event.inventory.InventoryClickEvent event)
      Executes when someone clicks to an item in this menu.
      Parameters:
      event - Instance of the event.
    • onClose

      public abstract void onClose(org.bukkit.event.inventory.InventoryCloseEvent event)
      Executes when someone closes this menu.
      Parameters:
      event - Instance of the event.
    • onOpen

      public abstract void onOpen(org.bukkit.event.inventory.InventoryOpenEvent event)
      Executes when someone opens this menu.
      Parameters:
      event - Instance of the event.
    • fill

      public abstract void fill()
      Main method to set menu items. Add the buttons, items and glass panes to your menu inside this method.
    • getInventory

      @NotNull public @NotNull org.bukkit.inventory.Inventory getInventory()
      Get the object's inventory.
      Specified by:
      getInventory in interface org.bukkit.inventory.InventoryHolder
      Returns:
      The inventory.
    • open

      public void open()
      Creates an inventory for this menu and shows it to the owner.
    • createItem

      protected org.bukkit.inventory.ItemStack createItem(org.bukkit.Material material, String displayName, String... lore)
      Quickly crates an ItemStack according to the parameters.
      Parameters:
      material - Type of the item.
      displayName - Display name of the item.
      lore - Lore of the item.
      Returns:
      ItemStack generated.
    • createSkull

      protected org.bukkit.inventory.ItemStack createSkull(org.bukkit.entity.Player owner, String displayName, String... lore)
      Quickly creates a skull owned by Player given.
      Parameters:
      owner - Owner of the skull
      displayName - Display name for the item
      lore - Lore for the item
      Returns:
      ItemStack generated. Guaranteed to be an Material.PLAYER_HEAD.
    • back

      protected void back()
      Closes this menu and open the last menu player visited before this one.
    • refresh

      protected void refresh()
      Refreshes the menu items.
    • fillEmptyWith

      protected void fillEmptyWith(org.bukkit.inventory.ItemStack tem)
      Fills all the empty slots with the ItemStack given.
      Parameters:
      tem - An ItemStack to put in every empty slot.
    • getSlots

      public int getSlots()
      Returns the real slot amount of this menu, which is getRows()*9.
      Returns:
      Slot amount of this menu.