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 GUI -
Method Summary
Modifier and TypeMethodDescriptionabstract org.bukkit.inventory.InventoryCreates a new Bukkit Inventory for the GUI when implementedvoiddispatchAdd(org.bukkit.event.Cancellable event, GUISection section, Vector2d position, org.bukkit.inventory.ItemStack item, int amount) Dispatches an add actionvoiddispatchAmount(org.bukkit.event.Cancellable event, GUISection section, Vector2d position, int amount) Dispatches an amount actionvoiddispatchRemove(org.bukkit.event.Cancellable event, GUISection section, Vector2d position) Dispatches a remove actionList<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 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 InventoryvoidonInventoryClose(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 Inventoryabstract voidprovideItem(org.bukkit.inventory.ItemStack itemStack) Used to provide items on MOVE_TO_OTHER_INVENTORY click eventvoidReloads all Views (Removes all Players and adds all Players).protected voidrender()Renders the GUIabstract List<org.bukkit.inventory.ItemStack>Renders the GUI on a listabstract GUISection.SearchDatasearchSection(int slot, boolean onlyPanes) Returns the GUISection at a specific slot.showPlayer(org.bukkit.entity.Player player) Shows the GUI to a player.voidupdate()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
-
-
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
-
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
-
searchSection
Returns the GUISection at a specific slot.- Parameters:
slot- The slotonlyPanes- Whether to return only panes even if there is an item at the clicked slot- Returns:
- The GUISection at the slot or null
-
provideItem
public abstract void provideItem(org.bukkit.inventory.ItemStack itemStack) Used to provide items on MOVE_TO_OTHER_INVENTORY click event- Parameters:
itemStack- The ItemStack that is provided
-
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 -
onInventoryClick
public void onInventoryClick(org.bukkit.event.inventory.InventoryClickEvent event) Called by Bukkit when Player clicks an Inventory- Parameters:
event- The Event
-
dispatchAdd
public void dispatchAdd(org.bukkit.event.Cancellable event, GUISection section, Vector2d position, org.bukkit.inventory.ItemStack item, int amount) Dispatches an add action- Parameters:
event- The eventsection- The sectionposition- The positionitem- The itemStack that got addedamount- The amount of the itemStack
-
dispatchRemove
public void dispatchRemove(org.bukkit.event.Cancellable event, GUISection section, Vector2d position) Dispatches a remove action- Parameters:
event- The eventsection- The sectionposition- The position
-
dispatchAmount
public void dispatchAmount(org.bukkit.event.Cancellable event, GUISection section, Vector2d position, int amount) Dispatches an amount action- Parameters:
event- The eventsection- The sectionposition- The positionamount- The new amount
-
onInventoryDrag
public void onInventoryDrag(org.bukkit.event.inventory.InventoryDragEvent event) Called by Bukkit when Player drags an Inventory- 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
-