Interface GuiElement
- All Known Implementing Classes:
GuiAnimatedItem, GuiButton, GuiItem, StateCycleElement, ToggleElement
public interface GuiElement
Represents an interactive component within a GUI.
Elements are responsible for their own visual representation (rendering) and handling user interactions such as clicking and dragging.
-
Method Summary
Modifier and TypeMethodDescriptiondefault ActionResultonClick(GuiClickContext ctx) Handles a player clicking on this element.default ActionResultonClick(GuiView view, int slot, org.bukkit.event.inventory.ClickType click, org.bukkit.inventory.ItemStack cursor, org.bukkit.inventory.ItemStack current) Deprecated, for removal: This API element is subject to removal in a future version.default ActionResultonDrag(GuiDragContext ctx) Handles items being dragged across slots containing this element.default ActionResultDeprecated, for removal: This API element is subject to removal in a future version.org.bukkit.inventory.ItemStackDetermines the visual representation of this element for a specific slot.
-
Method Details
-
render
Determines the visual representation of this element for a specific slot.- Parameters:
view- the active GUI viewslot- the slot index being rendered- Returns:
- the ItemStack to display, or null for an empty slot
-
onClick
@Deprecated(since="v2.0.0-mc1.21.11-dev.3", forRemoval=true) default ActionResult onClick(GuiView view, int slot, org.bukkit.event.inventory.ClickType click, @Nullable org.bukkit.inventory.ItemStack cursor, @Nullable org.bukkit.inventory.ItemStack current) Deprecated, for removal: This API element is subject to removal in a future version.Handles a player clicking on this element.- Parameters:
view- the active GUI viewslot- the slot index that was clickedclick- the type of click performedcursor- the item currently held on the cursor, if anycurrent- the item currently in the clicked slot, if any- Returns:
- the result of the action, determining if the event should be cancelled
-
onClick
Handles a player clicking on this element.- Parameters:
ctx- the context for the InventoryClickEvent- Returns:
- the result of the action, determining if the event should be cancelled
-
onDrag
@Deprecated(since="v2.0.0-mc1.21.11-dev.3", forRemoval=true) default ActionResult onDrag(GuiView view, Map<Integer, org.bukkit.inventory.ItemStack> addedItems) Deprecated, for removal: This API element is subject to removal in a future version.Handles items being dragged across slots containing this element.- Parameters:
view- the active GUI viewaddedItems- a map of slot indices to the item stacks being placed- Returns:
- the result of the action, determining if the event should be cancelled
-
onDrag
Handles items being dragged across slots containing this element.- Parameters:
ctx- the context for the InventoryDragEvent- Returns:
- the result of the action, determining if the event should be cancelled
-
onClick(GuiClickContext)