Package me.efekos.simpler.menu
Class Menu
java.lang.Object
me.efekos.simpler.menu.Menu
- All Implemented Interfaces:
org.bukkit.inventory.InventoryHolder
- Direct Known Subclasses:
PaginatedMenu
Represents a custom menu. Extend this class to make your custom menus.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
back()
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 anItemStack
according to the parameters.protected org.bukkit.inventory.ItemStack
createSkull
(org.bukkit.entity.Player owner, String displayName, String... lore) Quickly creates a skull owned byPlayer
given.abstract void
fill()
Main method to set menu items.protected void
fillEmptyWith
(org.bukkit.inventory.ItemStack tem) Fills all the empty slots with theItemStack
given.@NotNull org.bukkit.inventory.Inventory
Get the object's inventory.abstract int
getRows()
Returns a row amount for this menu.int
getSlots()
Returns the real slot amount of this menu, which isgetRows()
*9.abstract String
getTitle()
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
open()
Creates an inventory for this menu and shows it to theowner
.protected void
refresh()
Refreshes the menu items.
-
Field Details
-
inventory
protected org.bukkit.inventory.Inventory inventoryCurrent inventory that is being used by this holder. -
owner
protected org.bukkit.entity.Player ownerPlayer
who interacted with this menu. -
data
Temporarily data about the owner. You can store something about thisPlayer
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
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 interfaceorg.bukkit.inventory.InventoryHolder
- Returns:
- The inventory.
-
open
public void open()Creates an inventory for this menu and shows it to theowner
. -
createItem
protected org.bukkit.inventory.ItemStack createItem(org.bukkit.Material material, String displayName, String... lore) Quickly crates anItemStack
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 byPlayer
given.- Parameters:
owner
- Owner of the skulldisplayName
- Display name for the itemlore
- Lore for the item- Returns:
ItemStack
generated. Guaranteed to be anMaterial.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 theItemStack
given.- Parameters:
tem
- AnItemStack
to put in every empty slot.
-
getSlots
public int getSlots()Returns the real slot amount of this menu, which isgetRows()
*9.- Returns:
- Slot amount of this menu.
-