public abstract class GUI extends Object
This GUI framework relies on an implementing listener that handles inventory clicks, closes and opens.
Modifier and Type | Field and Description |
---|---|
protected org.bukkit.entity.Player |
player |
Constructor and Description |
---|
GUI(org.bukkit.entity.Player player,
String name,
int rows,
boolean cancelEvent)
Constructs a new GUI instance with the specified parameters.
|
Modifier and Type | Method and Description |
---|---|
void |
border(String name,
List<String> lore) |
boolean |
cancelEvent()
Determines whether events, such as clicks, within the GUI should be cancelled.
|
int |
getSize()
Calculates the total size of the GUI's inventory based on the number of rows.
|
boolean |
isOpen()
Checks if the GUI is currently open.
|
abstract void |
onClick(int row,
int column,
org.bukkit.inventory.ItemStack item,
org.bukkit.event.inventory.ClickType clickType)
Abstract method invoked when a click action occurs within the GUI at a specified row and column.
|
void |
open()
Opens the GUI for the player associated with this instance, initializing its content based on the provided configuration.
|
void |
setItem(int row,
int column,
GUIItem item)
Sets a
GUIItem at the specified row and column in the GUI. |
void |
updateItem(int row,
int column,
GUIItem item)
Updates the item in the specified row and column of the GUI.
|
public GUI(org.bukkit.entity.Player player, String name, int rows, boolean cancelEvent)
player
- The player who will interact with the GUI.name
- The display name of the GUI.rows
- The number of rows in the GUI, which must be between 0 and 5 inclusive.cancelEvent
- Determines whether the click events in the GUI will be cancelled.InvalidRowException
- If the number of rows is outside the valid range (0 to 5).public void setItem(int row, int column, GUIItem item)
GUIItem
at the specified row and column in the GUI.
The row and column indices must be within their respective valid ranges.
This will not update the GUI if it is already open.row
- The row index where the item will be placed. Must be between 0 and 5 inclusive.column
- The column index where the item will be placed. Must be between 0 and 8 inclusive.item
- The GUIItem
to be placed at the specified position. Can be null to clear the slot.InvalidRowException
- If the row index is not within the range 0-5.InvalidColumnException
- If the column index is not within the range 0-8.public void updateItem(int row, int column, GUIItem item)
row
- The row index to update. Must be between 0 and 5 inclusive.column
- The column index to update. Must be between 0 and 8 inclusive.item
- The GUIItem
to set at the specified position. If null, the corresponding slot
in the inventory will be cleared.public void open()
The method creates an inventory with dimensions determined by the rows and columns defined in this instance. Each slot of the inventory is populated with items from the internal inventory data structure, retaining the layout specified during the GUI's construction or modification.
Once the inventory is prepared, it is displayed to the player and registered for tracking in the
HubParkourAPI
. If the player's open inventory is null after attempting to open, the method exits early.
public int getSize()
public abstract void onClick(int row, int column, org.bukkit.inventory.ItemStack item, org.bukkit.event.inventory.ClickType clickType)
row
- The row index of the clicked slot. Must be between 0 and 5 inclusive.column
- The column index of the clicked slot. Must be between 0 and 8 inclusive.item
- The ItemStack present in the clicked slot. Can be null if the slot is empty.clickType
- The type of click action performed (e.g., left-click, right-click, shift-click).public boolean cancelEvent()
public boolean isOpen()
Copyright © 2025. All rights reserved.