Class GUI
java.lang.Object
de.placeblock.betterinventories.gui.GUI
- Direct Known Subclasses:
BaseAnvilGUI,BaseCanvasGUI,CartographyGUI
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classGUI.Builder<B extends GUI.Builder<B,G, P>, G extends GUI, P extends org.bukkit.plugin.java.JavaPlugin> The generic Builder for GUIs -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic de.placeblock.betterinventories.nms.NMSBridgeNMS Bridge is used for NMS specific code -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedGUI(org.bukkit.plugin.Plugin plugin, net.kyori.adventure.text.TextComponent title, org.bukkit.event.inventory.InventoryType type, boolean removeItems) Creates a new GUI -
Method Summary
Modifier and TypeMethodDescriptionabstract org.bukkit.inventory.InventoryCreates a new Bukkit Inventory for the GUI when implementedList<org.bukkit.entity.Player>abstract intgetSlots()getView(org.bukkit.entity.Player player) Returns the GUIView of the playergetView(org.bukkit.inventory.Inventory inventory) Returns the GUIView for the according Inventoryprotected voidonClose(org.bukkit.entity.Player player) Is called when the player closes the GUI.abstract voidprovideItem(org.bukkit.inventory.ItemStack itemStack) Used to provide items to GUIPanes.protected voidReloads all Views (Removes all Players and adds all Players).voidremovePlayer(GUIView view) Removes a player without closing the Inventory of the Playerprotected abstract List<org.bukkit.inventory.ItemStack>Renders the GUI on a listabstract voidsearchSection(SearchData searchData) Searches the GUISection recursively.showPlayer(org.bukkit.entity.Player player) Shows the GUI to a player.voidupdate()Updates the GUI, renders the GUI and updates the ViewsvoidupdateTitle(net.kyori.adventure.text.TextComponent title) Updates the title of the inventory
-
Field Details
-
NMS_BRIDGE
public static de.placeblock.betterinventories.nms.NMSBridge NMS_BRIDGENMS Bridge is used for NMS specific code
-
-
Constructor Details
-
GUI
protected GUI(org.bukkit.plugin.Plugin plugin, net.kyori.adventure.text.TextComponent title, org.bukkit.event.inventory.InventoryType type, boolean removeItems) Creates a new GUI- Parameters:
plugin- The plugintitle- The title of the GUItype- The type of the GUIremoveItems- Whether to remove loose items on close. The first player that closes the gui gets the items
-
-
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 for the according Inventory- Parameters:
inventory- The Inventory- Returns:
- The GUIView
-
getView
Returns the GUIView of the player- Parameters:
player- The Player- Returns:
- The GUIView
-
getSlots
public abstract int getSlots()- Returns:
- The amount of slots this GUI has
-
renderContent
Renders the GUI on a list- Returns:
- The List
-
searchSection
Searches the GUISection recursively. The SearchData is filled recursively.- Parameters:
searchData- The searchData that contains all needed information
-
provideItem
public abstract void provideItem(org.bukkit.inventory.ItemStack itemStack) Used to provide items to GUIPanes. The amount of the ItemStack will be modified if a pane accepted an ItemStack.- Parameters:
itemStack- The ItemStack that is provided.
-
update
public void update()Updates the GUI, renders the GUI and updates the Views -
reloadViews
protected void reloadViews()Reloads all Views (Removes all Players and adds all Players). Needed when resizing the GUI or changing the GUI's title -
updateTitle
public void updateTitle(net.kyori.adventure.text.TextComponent title) Updates the title of the inventory- Parameters:
title- The new title
-
removePlayer
Removes a player without closing the Inventory of the Player- Parameters:
view- The View of the Player
-
onClose
protected void onClose(org.bukkit.entity.Player player) Is called when the player closes the GUI.- Parameters:
player- The player, who closed the GUI
-