public final class MenuBuilder extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Map<Integer,MenuAction> |
actions |
protected boolean |
allowItemPickup |
protected boolean |
cancelLowerInvClick |
protected org.bukkit.inventory.ItemStack[] |
initialContents |
protected Map<Integer,MenuElement> |
items |
Menu.InventoryRows |
numberOfRows |
protected String |
title |
| Constructor and Description |
|---|
MenuBuilder(Menu.InventoryRows rows,
String title)
Create a new MenuBuilder with a number of rows and a title.
|
MenuBuilder(Menu.InventoryRows rows,
String title,
org.bukkit.inventory.ItemStack[] initialContents)
Create a new MenuBuilder with rows, title and initial contents.
|
| Modifier and Type | Method and Description |
|---|---|
ElementBuilder |
addElement(org.bukkit.inventory.ItemStack item)
Add a previously styled ItemStack directly to the menu.
|
ElementBuilder |
addElement(org.bukkit.inventory.ItemStack item,
String text,
String... lore)
Add an ItemStack to the menu of specified display name and lore.
|
MenuBuilder |
cancelLowerInventoryClicks(boolean toCancel)
Should ALL clicks on the lower inventory be cancelled as well?
|
Menu |
create(org.bukkit.plugin.java.JavaPlugin yourPlugin)
Create the Menu specified by the contents of this builder.
|
MenuBuilder |
defaultClickBehavior(boolean allowPickup)
Determine default pickup behavior when clicking ItemStacks.
|
MenuBuilder |
setInitialContents(org.bukkit.inventory.ItemStack[] contents)
Set the initial contents of the inventory.
|
MenuBuilder |
setTitle(String title)
Set a new title for the menu
|
public final Menu.InventoryRows numberOfRows
protected final Map<Integer,MenuElement> items
protected final Map<Integer,MenuAction> actions
protected String title
protected org.bukkit.inventory.ItemStack[] initialContents
protected boolean cancelLowerInvClick
protected boolean allowItemPickup
public MenuBuilder(Menu.InventoryRows rows, String title)
Menu will be blank and elements added.
rows - Menu.InventoryRows number to generatetitle - Title of generated inventorypublic MenuBuilder(Menu.InventoryRows rows, String title, org.bukkit.inventory.ItemStack[] initialContents)
rows - number of rowstitle - Title of generated inventoryinitialContents - an array of items to prefill the menu withpublic MenuBuilder setTitle(String title)
title - a new title for the generate menupublic MenuBuilder setInitialContents(org.bukkit.inventory.ItemStack[] contents)
This happens after creation of the inventory but before menu elements are processed.
contents - an array of itemspublic MenuBuilder defaultClickBehavior(boolean allowPickup)
Defaults to false. You can set this true and set different pickup logic for specific elements (for instance, an item vault system with pagination, possibly a sub-menu).
allowPickup - whether to allow item pickuppublic MenuBuilder cancelLowerInventoryClicks(boolean toCancel)
False by default.
toCancel - true to cancel clicks on lowerpublic ElementBuilder addElement(org.bukkit.inventory.ItemStack item)
This is useful if you're used to managing your own custom items. Your item will not be altered.
item - item to addpublic ElementBuilder addElement(org.bukkit.inventory.ItemStack item, String text, String... lore)
Recommended if you are not used to altering ItemMetas. Handles styling for you.
item - item to addtext - display name of itemlore - optional lore to add as varargspublic Menu create(org.bukkit.plugin.java.JavaPlugin yourPlugin)
Requires plugin reference for event syncing.
yourPlugin - an instance of your pluginCopyright © 2021. All rights reserved.