Class BaseInventoryPage
java.lang.Object
mc.obliviate.inventory.Gui
com.ultikits.ultitools.abstracts.gui.BaseInventoryPage
- All Implemented Interfaces:
org.bukkit.inventory.InventoryHolder
- Direct Known Subclasses:
BaseConfirmationPage,BasePaginationPage
public abstract class BaseInventoryPage
extends mc.obliviate.inventory.Gui
Base class for inventory GUI pages with common functionality.
Uses Template Method pattern to allow customization while providing standard behaviors.
- Since:
- 6.2.0
- Version:
- 2.0.0
- Author:
- wisdomme
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Consumer<org.bukkit.event.inventory.InventoryCloseEvent> Custom close handlerprotected static final intDefault slot for the last row backgroundprivate booleanWhether to show the bottom toolbarFields inherited from class mc.obliviate.inventory.Gui
player -
Constructor Summary
ConstructorsConstructorDescriptionBaseInventoryPage(@NotNull org.bukkit.entity.Player player, @NotNull String id, String title, int rows) BaseInventoryPage(@NotNull org.bukkit.entity.Player player, @NotNull String id, String title, org.bukkit.event.inventory.InventoryType inventoryType) BaseInventoryPage(@NotNull org.bukkit.entity.Player player, @NotNull String id, net.kyori.adventure.text.Component title, int rows) BaseInventoryPage(@NotNull org.bukkit.entity.Player player, @NotNull String id, net.kyori.adventure.text.Component title, org.bukkit.event.inventory.InventoryType inventoryType) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddToBottomRow(int column, mc.obliviate.inventory.Icon icon) Adds an item to the last row at the specified column.protected voidafterSetup(org.bukkit.event.inventory.InventoryOpenEvent event) Hook called after setup is complete.protected mc.obliviate.inventory.IconcreateActionButton(Colors color, String name, Consumer<org.bukkit.event.inventory.InventoryClickEvent> onClick) Creates an action button with the specified color and name.protected mc.obliviate.inventory.IconCreates the background icon for the toolbar.protected voidfillArea(mc.obliviate.inventory.Icon icon, int startSlot, int endSlot) Fills a rectangular area with the specified icon.protected voidfillBorder(mc.obliviate.inventory.Icon icon) Fills the border of the inventory with the specified icon.protected intGets the slot number at the center of the last row.protected int[]Gets the content area slots (excluding the last row if toolbar is shown).protected intgetSlotFromEnd(int fromEnd) Gets the slot number at the specified position from the end.Sets a custom close handler.voidonClose(org.bukkit.event.inventory.InventoryCloseEvent event) final voidonOpen(org.bukkit.event.inventory.InventoryOpenEvent event) Template method called when the GUI is opened.voidrefresh()Refreshes the GUI by re-opening it.setShowBottomToolbar(boolean show) Sets whether to show the bottom toolbar.protected voidSets up the standard bottom toolbar with gray background.protected abstract voidsetupContent(org.bukkit.event.inventory.InventoryOpenEvent event) Sets up the GUI content.Methods inherited from class mc.obliviate.inventory.Gui
addItem, addItem, addItem, addItem, addItem, addItem, addItem, addItem, createInventory, createInventory, fillColumn, fillGui, fillGui, fillGui, fillGui, fillRow, getId, getInventory, getItems, getLastSlot, getPlugin, getSize, getTaskList, getTitle, isClosed, onClick, onDrag, open, runTaskLater, sendSizeUpdate, sendTitleUpdate, setClosed, setInventory, setSize, setTitle, stopAllTasks, stopTask, updateTask
-
Field Details
-
DEFAULT_BOTTOM_ROW
protected static final int DEFAULT_BOTTOM_ROWDefault slot for the last row background- See Also:
-
showBottomToolbar
private boolean showBottomToolbarWhether to show the bottom toolbar -
closeHandler
Custom close handler
-
-
Constructor Details
-
BaseInventoryPage
-
BaseInventoryPage
-
BaseInventoryPage
public BaseInventoryPage(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull String id, net.kyori.adventure.text.Component title, int rows) -
BaseInventoryPage
public BaseInventoryPage(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull String id, net.kyori.adventure.text.Component title, org.bukkit.event.inventory.InventoryType inventoryType)
-
-
Method Details
-
onOpen
public final void onOpen(org.bukkit.event.inventory.InventoryOpenEvent event) Template method called when the GUI is opened. Subclasses should overridesetupContent(InventoryOpenEvent)to add content.- Overrides:
onOpenin classmc.obliviate.inventory.Gui
-
setupContent
protected abstract void setupContent(org.bukkit.event.inventory.InventoryOpenEvent event) Sets up the GUI content. Override this method to add custom content.- Parameters:
event- the inventory open event
-
afterSetup
protected void afterSetup(org.bukkit.event.inventory.InventoryOpenEvent event) Hook called after setup is complete. Override for additional customization.- Parameters:
event- the inventory open event
-
setupBottomToolbar
protected void setupBottomToolbar()Sets up the standard bottom toolbar with gray background. -
createBackgroundIcon
protected mc.obliviate.inventory.Icon createBackgroundIcon()Creates the background icon for the toolbar. Override to customize the background.- Returns:
- the background icon
-
createActionButton
protected mc.obliviate.inventory.Icon createActionButton(Colors color, String name, Consumer<org.bukkit.event.inventory.InventoryClickEvent> onClick) Creates an action button with the specified color and name.- Parameters:
color- the button colorname- the button nameonClick- the click handler- Returns:
- the created icon
-
addToBottomRow
protected void addToBottomRow(int column, mc.obliviate.inventory.Icon icon) Adds an item to the last row at the specified column. Column 0 is the leftmost slot.- Parameters:
column- the column (0-8 for 9-slot rows)icon- the icon to add
-
getBottomCenterSlot
protected int getBottomCenterSlot()Gets the slot number at the center of the last row.- Returns:
- the center slot of the last row
-
getSlotFromEnd
protected int getSlotFromEnd(int fromEnd) Gets the slot number at the specified position from the end.- Parameters:
fromEnd- position from the end (1 = last slot)- Returns:
- the slot number
-
setShowBottomToolbar
Sets whether to show the bottom toolbar.- Parameters:
show- true to show, false to hide- Returns:
- this page for method chaining
-
onClose
Sets a custom close handler.- Parameters:
handler- the close handler- Returns:
- this page for method chaining
-
onClose
public void onClose(org.bukkit.event.inventory.InventoryCloseEvent event) - Overrides:
onClosein classmc.obliviate.inventory.Gui
-
refresh
public void refresh()Refreshes the GUI by re-opening it. -
fillArea
protected void fillArea(mc.obliviate.inventory.Icon icon, int startSlot, int endSlot) Fills a rectangular area with the specified icon.- Parameters:
icon- the icon to fill withstartSlot- the starting slot (top-left)endSlot- the ending slot (bottom-right)
-
fillBorder
protected void fillBorder(mc.obliviate.inventory.Icon icon) Fills the border of the inventory with the specified icon.- Parameters:
icon- the icon to use for the border
-
getContentSlots
protected int[] getContentSlots()Gets the content area slots (excluding the last row if toolbar is shown).- Returns:
- array of content slot indices
-