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 Type
    Method
    Description
    default ActionResult
    Handles a player clicking on this element.
    default ActionResult
    onClick(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 ActionResult
    Handles items being dragged across slots containing this element.
    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.
    org.bukkit.inventory.ItemStack
    render(GuiView view, int slot)
    Determines the visual representation of this element for a specific slot.
  • Method Details

    • render

      @Nullable org.bukkit.inventory.ItemStack render(GuiView view, int slot)
      Determines the visual representation of this element for a specific slot.
      Parameters:
      view - the active GUI view
      slot - 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 view
      slot - the slot index that was clicked
      click - the type of click performed
      cursor - the item currently held on the cursor, if any
      current - the item currently in the clicked slot, if any
      Returns:
      the result of the action, determining if the event should be cancelled
    • onClick

      default ActionResult onClick(GuiClickContext ctx)
      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 view
      addedItems - 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

      default ActionResult onDrag(GuiDragContext ctx)
      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