Class GuiClickEvent

java.lang.Object
org.bukkit.event.Event
tk.airshipcraft.commonlib.gui.events.GuiClickEvent
All Implemented Interfaces:
org.bukkit.event.Cancellable

public class GuiClickEvent extends org.bukkit.event.Event implements org.bukkit.event.Cancellable
Represents an event triggered when a player interacts with a Graphical User Interface (GUI) in the game. This event class encapsulates all the relevant information about the interaction, including the player involved, the specific item clicked, the slot index where the click occurred, and the inventory involved in the GUI. This event can be cancelled, allowing developers to control the outcome of the interaction.
Since:
2023-04-09
Version:
1.0.0
Author:
Locutusque
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.bukkit.event.Event

    org.bukkit.event.Event.Result
  • Constructor Summary

    Constructors
    Constructor
    Description
    GuiClickEvent(org.bukkit.entity.Player player, int slot, org.bukkit.inventory.ItemStack item, org.bukkit.inventory.Inventory inventory)
    Constructs a new GuiClickEvent with the specified details of the player's interaction with the GUI.
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.bukkit.event.HandlerList
    Returns the HandlerList for this event type.
    org.bukkit.event.HandlerList
    Returns the handlers associated with this event.
    org.bukkit.inventory.Inventory
    Gets the Inventory object associated with the GUI that was clicked.
    org.bukkit.inventory.ItemStack
    Retrieves the ItemStack at the slot that was clicked.
    int
    Gets the index of the slot that was clicked in the GUI.
    org.bukkit.entity.Player
    Gets the player who interacted with the GUI.
    boolean
    Checks if the event has been cancelled.
    void
    setCancelled(boolean cancelled)
    Sets the cancellation state of the event.

    Methods inherited from class org.bukkit.event.Event

    callEvent, getEventName, isAsynchronous

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GuiClickEvent

      public GuiClickEvent(org.bukkit.entity.Player player, int slot, org.bukkit.inventory.ItemStack item, org.bukkit.inventory.Inventory inventory)
      Constructs a new GuiClickEvent with the specified details of the player's interaction with the GUI.
      Parameters:
      player - The player who clicked in the GUI, not null.
      slot - The slot index in the inventory that was clicked.
      item - The ItemStack present at the clicked slot, can be null if the slot is empty.
      inventory - The inventory object associated with the GUI being interacted with, not null.
  • Method Details

    • getHandlerList

      public static org.bukkit.event.HandlerList getHandlerList()
      Returns the HandlerList for this event type. Required for custom event implementation in Bukkit.
      Returns:
      The static HandlerList for GuiClickEvent.
    • getWhoClicked

      public org.bukkit.entity.Player getWhoClicked()
      Gets the player who interacted with the GUI.
      Returns:
      The Player instance representing the player who clicked in the GUI.
    • getSlot

      public int getSlot()
      Gets the index of the slot that was clicked in the GUI.
      Returns:
      The zero-based index of the clicked slot.
    • getItem

      public org.bukkit.inventory.ItemStack getItem()
      Retrieves the ItemStack at the slot that was clicked.
      Returns:
      The ItemStack at the clicked slot, or null if the slot is empty.
    • getInventory

      public org.bukkit.inventory.Inventory getInventory()
      Gets the Inventory object associated with the GUI that was clicked.
      Returns:
      The Inventory instance representing the GUI's inventory.
    • isCancelled

      public boolean isCancelled()
      Checks if the event has been cancelled. A cancelled event will not proceed with the default interaction behavior.
      Specified by:
      isCancelled in interface org.bukkit.event.Cancellable
      Returns:
      True if the event is cancelled, false otherwise.
    • setCancelled

      public void setCancelled(boolean cancelled)
      Sets the cancellation state of the event. Cancelling the event can prevent the default interaction behavior associated with the GUI click.
      Specified by:
      setCancelled in interface org.bukkit.event.Cancellable
      Parameters:
      cancelled - True to cancel the event, false to allow it to proceed.
    • getHandlers

      public org.bukkit.event.HandlerList getHandlers()
      Returns the handlers associated with this event. Part of the Bukkit event handling mechanism.
      Specified by:
      getHandlers in class org.bukkit.event.Event
      Returns:
      The HandlerList for this event.