Class GuiButton
java.lang.Object
com.github.darksoulq.abyssallib.world.gui.element.GuiItem
com.github.darksoulq.abyssallib.world.gui.element.GuiButton
- All Implemented Interfaces:
GuiElement
An interactive GUI element that executes an action when clicked.
This element displays an item but executes a provided consumer logic when a player interacts with it. It is the primary way to create clickable controls in a GUI. (Item may be null)
-
Constructor Summary
ConstructorsConstructorDescriptionGuiButton(org.bukkit.inventory.ItemStack item, Consumer<GuiClickContext> action) Constructs a new GuiButton. -
Method Summary
Modifier and TypeMethodDescriptionstatic GuiButtonof(org.bukkit.inventory.ItemStack item, Consumer<GuiClickContext> action) Static factory method to create a GuiButton.onClick(GuiClickContext ctx) Executes the button action and cancels the inventory event.Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface GuiElement
onClick, onDrag
-
Constructor Details
-
GuiButton
Constructs a new GuiButton.- Parameters:
item- the button iconaction- the logic to run on click
-
-
Method Details
-
onClick
Executes the button action and cancels the inventory event.- Specified by:
onClickin interfaceGuiElement- Overrides:
onClickin classGuiItem- Parameters:
ctx- the click context- Returns:
ActionResult.CANCEL
-
of
Static factory method to create a GuiButton.- Parameters:
item- the item iconaction- the click logic- Returns:
- a new GuiButton instance
-