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
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract org.bukkit.inventory.Inventory
    Creates a new Bukkit Inventory for the GUI when implemented
    void
    dispatchAdd(org.bukkit.event.Cancellable event, GUISection section, Vector2d position, org.bukkit.inventory.ItemStack item, int amount)
    Dispatches an add action
    void
    dispatchAmount(org.bukkit.event.Cancellable event, GUISection section, Vector2d position, int amount)
    Dispatches an amount action
    void
    dispatchRemove(org.bukkit.event.Cancellable event, GUISection section, Vector2d position)
    Dispatches a remove action
    List<org.bukkit.entity.Player>
     
    abstract int
     
    getView(org.bukkit.entity.Player player)
    Returns the GUIView of the player
    getView(org.bukkit.inventory.Inventory inventory)
    Returns the GUIView for 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
    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
    abstract void
    provideItem(org.bukkit.inventory.ItemStack itemStack)
    Used to provide items on MOVE_TO_OTHER_INVENTORY click event
    void
    Reloads all Views (Removes all Players and adds all Players).
    protected void
    Renders the GUI
    abstract List<org.bukkit.inventory.ItemStack>
    Renders the GUI on a list
    searchSection(int slot, boolean onlyPanes)
    Returns the GUISection at a specific slot.
    showPlayer(org.bukkit.entity.Player player)
    Shows the GUI to a player.
    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
  • 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 for the according Inventory
      Parameters:
      inventory - The Inventory
      Returns:
      The GUIView
    • getView

      public GUIView getView(org.bukkit.entity.Player player)
      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

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

      public abstract GUISection.SearchData searchSection(int slot, boolean onlyPanes)
      Returns the GUISection at a specific slot.
      Parameters:
      slot - The slot
      onlyPanes - 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 event
      section - The section
      position - The position
      item - The itemStack that got added
      amount - 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 event
      section - The section
      position - The position
    • dispatchAmount

      public void dispatchAmount(org.bukkit.event.Cancellable event, GUISection section, Vector2d position, int amount)
      Dispatches an amount action
      Parameters:
      event - The event
      section - The section
      position - The position
      amount - 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