Package tk.airshipcraft.commonlib.gui
Class GuiManager
java.lang.Object
tk.airshipcraft.commonlib.gui.GuiManager
- All Implemented Interfaces:
org.bukkit.event.Listener
Provides management for GUI interactions within the server. It keeps track of active GUI instances
associated with players and dispatches inventory click events to the appropriate custom GUI handlers.
As a Listener, it is responsible for intercepting events from the Bukkit event system and processing
them as needed for custom GUI functionality.
- Since:
- 2023-11-20
- Version:
- 1.0.0
- Author:
- notzune
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
onInventoryClick
(org.bukkit.event.inventory.InventoryClickEvent event) Event handler that intercepts inventory click events within the server.void
registerGui
(org.bukkit.entity.Player player, Gui gui) Associates a GUI instance with a player for event handling.void
unregisterGui
(org.bukkit.entity.Player player) Removes the association between a player and a GUI.
-
Constructor Details
-
GuiManager
public GuiManager()
-
-
Method Details
-
registerGui
Associates a GUI instance with a player for event handling. This method registers the GUI to ensure that click events within it are processed correctly.- Parameters:
player
- The player for whom the GUI is to be registered.gui
- The Gui instance to associate with the player.
-
unregisterGui
public void unregisterGui(org.bukkit.entity.Player player) Removes the association between a player and a GUI. This is typically called when a GUI is no longer active or when the player closes it.- Parameters:
player
- The player whose association with a GUI is to be removed.
-
onInventoryClick
public void onInventoryClick(org.bukkit.event.inventory.InventoryClickEvent event) Event handler that intercepts inventory click events within the server. It checks if the event corresponds to an active custom GUI and, if so, cancels the default event behavior and passes the event to the custom GUI's own click handling logic.- Parameters:
event
- The InventoryClickEvent triggered by the player's interaction with an inventory.
-