java.lang.Object
de.placeblock.betterinventories.gui.GUI
Direct Known Subclasses:
BaseAnvilGUI, BaseCanvasGUI, CartographyGUI

public abstract class GUI extends Object
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 Classes
    Modifier and Type
    Class
    Description
    static class 
    GUI.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

    Fields
    Modifier and Type
    Field
    Description
    static de.placeblock.betterinventories.nms.NMSBridge
    NMS Bridge is used for NMS specific code
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    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
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract org.bukkit.inventory.Inventory
    Creates a new Bukkit Inventory for the GUI when implemented
    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
    protected void
    onClose(org.bukkit.entity.Player player)
    Is called when the player closes the GUI.
    abstract void
    provideItem(org.bukkit.inventory.ItemStack itemStack)
    Used to provide items to GUIPanes.
    protected void
    Reloads all Views (Removes all Players and adds all Players).
    void
    Removes a player without closing the Inventory of the Player
    protected abstract List<org.bukkit.inventory.ItemStack>
    Renders the GUI on a list
    abstract void
    Searches the GUISection recursively.
    showPlayer(org.bukkit.entity.Player player)
    Shows the GUI to a player.
    void
    Updates the GUI, renders the GUI and updates the Views
    void
    updateTitle(net.kyori.adventure.text.TextComponent title)
    Updates the title of the inventory

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • NMS_BRIDGE

      public static de.placeblock.betterinventories.nms.NMSBridge NMS_BRIDGE
      NMS 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 plugin
      title - The title of the GUI
      type - The type of the GUI
      removeItems - 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

      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
    • 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
    • searchSection

      public abstract void searchSection(SearchData searchData)
      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

      public void removePlayer(GUIView view)
      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