Class GUI
java.lang.Object
de.placeblock.betterinventories.gui.GUI
- All Implemented Interfaces:
org.bukkit.event.Listener
- Direct Known Subclasses:
AnvilGUI,BaseCanvasGUI
Root class for GUIs
Can be used to create any sort of GUI that can be rendered to a list
e.g. Chest, Hopper, Furnace, Anvil, Brewing.
However, for most of these examples there exist better methods for creating a GUI already.
-
Constructor Summary
ConstructorsConstructorDescriptionGUI(org.bukkit.plugin.Plugin plugin, net.kyori.adventure.text.TextComponent title, org.bukkit.event.inventory.InventoryType type) Creates a new GUIGUI(org.bukkit.plugin.Plugin plugin, net.kyori.adventure.text.TextComponent title, org.bukkit.event.inventory.InventoryType type, boolean registerDefaultHandlers) Creates a new GUI -
Method Summary
Modifier and TypeMethodDescriptionabstract org.bukkit.inventory.InventoryCreates a new Bukkit Inventory for the GUI when implementedabstract GUISectiongetClickedSection(int slot) Returns the GUISection at a specific slot.List<org.bukkit.entity.Player>abstract intgetSlots()getView(org.bukkit.inventory.Inventory inventory) Returns the GUIView to the according InventoryvoidonClose(org.bukkit.entity.Player player) Is called when the player closes the GUI.voidonInventoryClick(org.bukkit.event.inventory.InventoryClickEvent event) Called by Bukkit when Player clicks an Inventory Calls the InteractionHandlersvoidonInventoryClose(org.bukkit.event.inventory.InventoryCloseEvent event) Called by Bukkit when a Player closes an InventoryvoidonInventoryDrag(org.bukkit.event.inventory.InventoryDragEvent event) Called by Bukkit when Player drags an Inventory Calls the InteractionHandlersvoidregisterInteractionHandler(HandlerPriority priority, InteractionHandler handler) Registers a new InteractionHandler.voidReloads all Views (Removes all Players and adds all Players).protected voidrender()Renders the GUIprotected abstract List<org.bukkit.inventory.ItemStack>Renders the GUI on a listshowPlayer(org.bukkit.entity.Player player) Shows the GUI to a player.voidunregisterInteractionHandler(HandlerPriority priority, InteractionHandler handler) Unregisters a new InteractionHandlervoidupdate()Updates the GUI, renders the GUI and updates the Viewsprotected voidUpdates the content of all Views
-
Constructor Details
-
GUI
public GUI(org.bukkit.plugin.Plugin plugin, net.kyori.adventure.text.TextComponent title, org.bukkit.event.inventory.InventoryType type) Creates a new GUI- Parameters:
plugin- The plugintitle- The title of the GUItype- The type of the GUI
-
GUI
public GUI(org.bukkit.plugin.Plugin plugin, net.kyori.adventure.text.TextComponent title, org.bukkit.event.inventory.InventoryType type, boolean registerDefaultHandlers) Creates a new GUI- Parameters:
plugin- The plugintitle- The title of the GUItype- The type of the GUIregisterDefaultHandlers- Whether to register default-handlers
-
-
Method Details
-
createBukkitInventory
public abstract org.bukkit.inventory.Inventory createBukkitInventory()Creates a new Bukkit Inventory for the GUI when implemented- Returns:
- The Bukkit Inventory
-
showPlayer
Shows the GUI to a player.- Parameters:
player- The Player- Returns:
- The newly created GUIView
-
getPlayers
- Returns:
- All players, which can see the GUI
-
getView
Returns the GUIView to the according Inventory- Parameters:
inventory- The Inventory- Returns:
- The GUIView
-
reloadViews
public void reloadViews()Reloads all Views (Removes all Players and adds all Players). Needed when resizing the GUI or changing the GUI's title -
getSlots
public abstract int getSlots()- Returns:
- The amount of slots this GUI has
-
renderContent
Renders the GUI on a list- Returns:
- The List
-
getClickedSection
Returns the GUISection at a specific slot.- Parameters:
slot- The slot- Returns:
- The GUISection at the slot or null
-
update
public void update()Updates the GUI, renders the GUI and updates the Views -
render
protected void render()Renders the GUI -
updateViews
protected void updateViews()Updates the content of all Views -
registerInteractionHandler
Registers a new InteractionHandler. InteractionHandlers will receive Inventory Click- and DragEvents- Parameters:
priority- The priority for the new Handler.handler- The handler
-
unregisterInteractionHandler
Unregisters a new InteractionHandler- Parameters:
priority- The priority of the Handler.handler- The handler
-
onInventoryClick
public void onInventoryClick(org.bukkit.event.inventory.InventoryClickEvent event) Called by Bukkit when Player clicks an Inventory Calls the InteractionHandlers- Parameters:
event- The Event
-
onInventoryDrag
public void onInventoryDrag(org.bukkit.event.inventory.InventoryDragEvent event) Called by Bukkit when Player drags an Inventory Calls the InteractionHandlers- Parameters:
event- The Event
-
onInventoryClose
public void onInventoryClose(org.bukkit.event.inventory.InventoryCloseEvent event) Called by Bukkit when a Player closes an Inventory- Parameters:
event- The Event
-
onClose
public void onClose(org.bukkit.entity.Player player) Is called when the player closes the GUI.- Parameters:
player- The player, who closed the GUI
-