Package com.coderyo.coderyogui.api
Class GUIClickEvent
java.lang.Object
org.bukkit.event.Event
com.coderyo.coderyogui.api.GUIClickEvent
- All Implemented Interfaces:
org.bukkit.event.Cancellable
public class GUIClickEvent
extends org.bukkit.event.Event
implements org.bukkit.event.Cancellable
An event fired when a player clicks a slot in a CoderyoGUI custom GUI.
This event can be cancelled to prevent the execution of associated
GUIActions.-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
org.bukkit.event.Event.Result -
Constructor Summary
ConstructorsConstructorDescriptionGUIClickEvent(org.bukkit.entity.Player player, CustomGUI gui, int pageId, int slot, GUIItem item) Constructs a new GUIClickEvent.GUIClickEvent(org.bukkit.entity.Player player, CustomGUI gui, int pageId, int slot, GUIItem item, boolean isBackButton) Constructs a new GUIClickEvent with back button indicator. -
Method Summary
Modifier and TypeMethodDescriptiongetGui()Gets the CustomGUI that was clicked.static org.bukkit.event.HandlerListGets the static HandlerList for this event type.org.bukkit.event.HandlerListGets the list of event handlers.getItem()Gets the GUIItem in the clicked slot, if any.intGets the ID of the page clicked.org.bukkit.entity.PlayerGets the player who clicked the GUI.intgetSlot()Gets the slot index clicked.booleanChecks if the clicked slot is the back button (slot 0).booleanChecks if the event has been cancelled.voidsetCancelled(boolean cancelled) Sets whether the event is cancelled.Methods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
Constructor Details
-
GUIClickEvent
public GUIClickEvent(org.bukkit.entity.Player player, CustomGUI gui, int pageId, int slot, GUIItem item) Constructs a new GUIClickEvent.- Parameters:
player- The player who clicked the GUI.gui- The CustomGUI that was clicked.pageId- The ID of the page clicked.slot- The slot index clicked.item- The GUIItem in the slot, or null if the slot is empty.
-
GUIClickEvent
public GUIClickEvent(org.bukkit.entity.Player player, CustomGUI gui, int pageId, int slot, GUIItem item, boolean isBackButton) Constructs a new GUIClickEvent with back button indicator.- Parameters:
player- The player who clicked the GUI.gui- The CustomGUI that was clicked.pageId- The ID of the page clicked.slot- The slot index clicked.item- The GUIItem in the slot, or null if the slot is empty.isBackButton- True if the clicked slot is the back button (slot 0).
-
-
Method Details
-
getPlayer
public org.bukkit.entity.Player getPlayer()Gets the player who clicked the GUI.- Returns:
- The player.
-
getGui
Gets the CustomGUI that was clicked.- Returns:
- The CustomGUI instance.
-
getPageId
public int getPageId()Gets the ID of the page clicked.- Returns:
- The page ID.
-
getSlot
public int getSlot()Gets the slot index clicked.- Returns:
- The slot index.
-
getItem
Gets the GUIItem in the clicked slot, if any.- Returns:
- The GUIItem, or null if the slot is empty.
-
isBackButton
public boolean isBackButton()Checks if the clicked slot is the back button (slot 0).- Returns:
- True if the slot is the back button, false otherwise.
-
isCancelled
public boolean isCancelled()Checks if the event has been cancelled.- Specified by:
isCancelledin interfaceorg.bukkit.event.Cancellable- Returns:
- true if the event is cancelled, false otherwise.
-
setCancelled
public void setCancelled(boolean cancelled) Sets whether the event is cancelled. If cancelled, associatedGUIActionexecutions will be prevented.- Specified by:
setCancelledin interfaceorg.bukkit.event.Cancellable- Parameters:
cancelled- true to cancel the event, false to allow it.
-
getHandlers
public org.bukkit.event.HandlerList getHandlers()Gets the list of event handlers.- Specified by:
getHandlersin classorg.bukkit.event.Event- Returns:
- The HandlerList for this event.
-
getHandlerList
public static org.bukkit.event.HandlerList getHandlerList()Gets the static HandlerList for this event type.- Returns:
- The static HandlerList.
-