Package wbs.utils.util.menus
Class WbsMenu
java.lang.Object
wbs.utils.util.menus.WbsMenu
- All Implemented Interfaces:
org.bukkit.event.Listener
- Direct Known Subclasses:
PagedMenu
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected @Nullable Consumer<org.bukkit.event.inventory.InventoryCloseEvent>protected @Nullable BiConsumer<WbsMenu,org.bukkit.event.inventory.InventoryCloseEvent> protected final WbsPluginprotected final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intgetColumn(int rawSlot) protected intGet the number of the last slot in this menuprotected intgetRow(int rawSlot) protected intgetSlotNumber(int row, int column) Get the slot number for a given row and column.booleanhasMenuOpen(org.bukkit.entity.Player player) booleanisMenu(org.bukkit.inventory.InventoryView view) booleanvoidonClick(org.bukkit.event.inventory.InventoryClickEvent event) voidonClose(org.bukkit.event.inventory.InventoryCloseEvent event) voidregister()voidsetBanners(MenuSlot slot) Fill the first and last rows with the given slot.voidsetCloseAction(@Nullable Consumer<org.bukkit.event.inventory.InventoryCloseEvent> closeAction) voidsetCloseActionMenu(@Nullable BiConsumer<WbsMenu, org.bukkit.event.inventory.InventoryCloseEvent> closeActionMenu) voidFill a given column with the given slot.booleansetNextFreeSlot(int minRow, int maxRow, int minColumn, int maxColumn, MenuSlot slot) Set the next free slot in a rectangular region bound by a minimum and maximum row and column.booleansetNextFreeSlot(int minSlotCorner, int maxSlotCorner, MenuSlot slot) Set the next free slot in a rectangular region defined by two corners, where the first slot is the upper left corner, and the second slot is the lower right corner.booleansetNextFreeSlot(int startingAt, MenuSlot slot) Add a slot in the next available slot in the menu if any are availablebooleansetNextFreeSlot(MenuSlot slot) Add a slot in the next available slot in the menu if any are availablevoidsetOutline(MenuSlot slot) Helper method to set the outline of the menu to a specific slot.voidsetOutline(MenuSlot slot, boolean override) Helper method to set the outline of the menu to a specific slot.voidFill a given row with the given slot.voidvoidSet a menu slot for thisvoidsetUnregisterOnClose(boolean unregisterOnClose) voidshowTo(org.bukkit.entity.Player player) booleanUnregisters this menu, and closes it for any players that have it open.voidupdate()Update all slots for all players currently viewing this menuvoidupdate(int slot) Update the given slot for all players currently looking at this menu.voidupdate(int row, int column)
-
Field Details
-
plugin
-
rows
protected final int rows -
closeAction
-
closeActionMenu
@Nullable protected @Nullable BiConsumer<WbsMenu,org.bukkit.event.inventory.InventoryCloseEvent> closeActionMenu
-
-
Constructor Details
-
WbsMenu
- Parameters:
plugin- The plugin to register this menu totitle- The title of the menu to show to playersrows- How many rows to create, between 1 and 6 inclusiveid- A unique identifier for identifying inventory clicks
-
-
Method Details
-
update
public void update(int slot) Update the given slot for all players currently looking at this menu.- Parameters:
slot- The slot to update.
-
update
public void update(int row, int column) -
update
public void update()Update all slots for all players currently viewing this menu -
unregister
public boolean unregister()Unregisters this menu, and closes it for any players that have it open. Once unregistered, the menu will cease to function.- Returns:
- True any players had the menu open when it was unregistered.
-
isRegistered
public boolean isRegistered() -
register
public void register() -
setUnregisterOnClose
public void setUnregisterOnClose(boolean unregisterOnClose) -
showTo
public void showTo(org.bukkit.entity.Player player) -
hasMenuOpen
public boolean hasMenuOpen(org.bukkit.entity.Player player) -
isMenu
public boolean isMenu(org.bukkit.inventory.InventoryView view) -
onClose
public void onClose(org.bukkit.event.inventory.InventoryCloseEvent event) -
setCloseAction
public void setCloseAction(@Nullable @Nullable Consumer<org.bukkit.event.inventory.InventoryCloseEvent> closeAction) -
setCloseActionMenu
public void setCloseActionMenu(@Nullable @Nullable BiConsumer<WbsMenu, org.bukkit.event.inventory.InventoryCloseEvent> closeActionMenu) -
onClick
public void onClick(org.bukkit.event.inventory.InventoryClickEvent event) -
getMaxSlot
protected int getMaxSlot()Get the number of the last slot in this menu- Returns:
- The maximum slot this menu may contain
-
getSlotNumber
protected int getSlotNumber(int row, int column) Get the slot number for a given row and column.- Parameters:
row- The rowcolumn- The column- Returns:
- The slot number that represents the slot at the given row and column
-
getRow
protected int getRow(int rawSlot) -
getColumn
protected int getColumn(int rawSlot)
-