java.lang.Object
de.placeblock.betterinventories.gui.GUI
All Implemented Interfaces:
org.bukkit.event.Listener
Direct Known Subclasses:
AnvilGUI, BaseCanvasGUI

public abstract class GUI extends Object implements org.bukkit.event.Listener
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

    Constructors
    Constructor
    Description
    GUI(org.bukkit.plugin.Plugin plugin, net.kyori.adventure.text.TextComponent title, org.bukkit.event.inventory.InventoryType type)
    Creates a new GUI
    GUI(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 Type
    Method
    Description
    abstract org.bukkit.inventory.Inventory
    Creates a new Bukkit Inventory for the GUI when implemented
    abstract GUISection
    Returns the GUISection at a specific slot.
    List<org.bukkit.entity.Player>
     
    abstract int
     
    getView(org.bukkit.inventory.Inventory inventory)
    Returns the GUIView to the according Inventory
    void
    onClose(org.bukkit.entity.Player player)
    Is called when the player closes the GUI.
    void
    onInventoryClick(org.bukkit.event.inventory.InventoryClickEvent event)
    Called by Bukkit when Player clicks an Inventory Calls the InteractionHandlers
    void
    onInventoryClose(org.bukkit.event.inventory.InventoryCloseEvent event)
    Called by Bukkit when a Player closes an Inventory
    void
    onInventoryDrag(org.bukkit.event.inventory.InventoryDragEvent event)
    Called by Bukkit when Player drags an Inventory Calls the InteractionHandlers
    void
    Registers a new InteractionHandler.
    void
    Reloads all Views (Removes all Players and adds all Players).
    protected void
    Renders the GUI
    protected abstract List<org.bukkit.inventory.ItemStack>
    Renders the GUI on a list
    showPlayer(org.bukkit.entity.Player player)
    Shows the GUI to a player.
    void
    Unregisters a new InteractionHandler
    void
    Updates the GUI, renders the GUI and updates the Views
    protected void
    Updates the content of all Views

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 plugin
      title - The title of the GUI
      type - 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 plugin
      title - The title of the GUI
      type - The type of the GUI
      registerDefaultHandlers - 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

      public GUIView showPlayer(org.bukkit.entity.Player player)
      Shows the GUI to a player.
      Parameters:
      player - The Player
      Returns:
      The newly created GUIView
    • getPlayers

      public List<org.bukkit.entity.Player> getPlayers()
      Returns:
      All players, which can see the GUI
    • getView

      public GUIView getView(org.bukkit.inventory.Inventory inventory)
      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

      protected abstract List<org.bukkit.inventory.ItemStack> renderContent()
      Renders the GUI on a list
      Returns:
      The List
    • getClickedSection

      public abstract GUISection getClickedSection(int slot)
      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

      public void registerInteractionHandler(HandlerPriority priority, InteractionHandler handler)
      Registers a new InteractionHandler. InteractionHandlers will receive Inventory Click- and DragEvents
      Parameters:
      priority - The priority for the new Handler.
      handler - The handler
    • unregisterInteractionHandler

      public void unregisterInteractionHandler(HandlerPriority priority, InteractionHandler handler)
      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