Class ChestGui

All Implemented Interfaces:
InventoryBased, MergedGui, InventoryHolder

public class ChestGui extends NamedGui implements MergedGui, InventoryBased
Represents a gui in the form of a chest. Unlike traditional chests, this may take on any amount of rows between 1 and 6.
Since:
0.8.0
  • Constructor Details

    • ChestGui

      public ChestGui(int rows, @NotNull @NotNull String title)
      Constructs a new chest GUI
      Parameters:
      rows - the amount of rows this gui should contain, in range 1..6.
      title - the title/name of this gui.
      Since:
      0.8.0
    • ChestGui

      public ChestGui(int rows, @NotNull @NotNull com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder title)
      Constructs a new chest GUI
      Parameters:
      rows - the amount of rows this gui should contain, in range 1..6.
      title - the title/name of this gui.
      Since:
      0.10.0
    • ChestGui

      public ChestGui(int rows, @NotNull @NotNull String title, @NotNull @NotNull Plugin plugin)
      Constructs a new chest gui for the given plugin.
      Parameters:
      rows - the amount of rows this gui should contain, in range 1..6.
      title - the title/name of this gui.
      plugin - the owning plugin of this gui
      Since:
      0.10.8
      See Also:
    • ChestGui

      public ChestGui(int rows, @NotNull @NotNull com.github.stefvanschie.inventoryframework.adventuresupport.TextHolder title, @NotNull @NotNull Plugin plugin)
      Constructs a new chest gui for the given plugin.
      Parameters:
      rows - the amount of rows this gui should contain, in range 1..6.
      title - the title/name of this gui.
      plugin - the owning plugin of this gui
      Since:
      0.10.8
      See Also:
  • Method Details

    • update

      public void update()
      Description copied from class: Gui
      Update the gui for everyone
      Specified by:
      update in class Gui
    • show

      public void show(@NotNull @NotNull HumanEntity humanEntity)
      Description copied from class: Gui
      Shows a gui to a player
      Specified by:
      show in class Gui
      Parameters:
      humanEntity - the human entity to show the gui to
    • copy

      @NotNull @Contract(pure=true) public @NotNull ChestGui copy()
      Description copied from class: Gui
      Makes a copy of this gui and returns it. This makes a deep copy of the gui. This entails that the underlying panes will be copied as per their Pane.copy() and miscellaneous data will be copied. The copy of this gui, will however have no viewers even if this gui currently has viewers. With this, cache data for viewers will also be non-existent for the copied gui. The original owning plugin of the gui is preserved, but the plugin will not be deeply copied. The returned gui will never be reference equal to the current gui.
      Specified by:
      copy in class Gui
      Returns:
      a copy of the gui
    • click

      public void click(@NotNull @NotNull InventoryClickEvent event)
      Description copied from class: Gui
      This should delegate the provided inventory click event to the right pane, which can then handle this click event further. This should not call any internal click handlers, since those will already have been activated.
      Specified by:
      click in class Gui
      Parameters:
      event - the event to delegate
    • isPlayerInventoryUsed

      @Contract(pure=true) public boolean isPlayerInventoryUsed()
      Description copied from class: Gui
      Gets whether the player inventory is currently in use. This means whether the player inventory currently has an item in it.
      Specified by:
      isPlayerInventoryUsed in class Gui
      Returns:
      true if the player inventory is occupied, false otherwise
    • setRows

      public void setRows(int rows)
      Sets the amount of rows for this inventory. This will (unlike most other methods) directly update itself in order to ensure all viewers will still be viewing the new inventory as well.
      Parameters:
      rows - the amount of rows in range 1..6.
      Since:
      0.8.0
    • getInventory

      @NotNull public @NotNull Inventory getInventory()
      Specified by:
      getInventory in interface InventoryHolder
    • addPane

      public void addPane(@NotNull @NotNull Slot slot, @NotNull @NotNull Pane pane)
      Description copied from interface: MergedGui
      Adds a pane to this gui
      Specified by:
      addPane in interface MergedGui
      Parameters:
      slot - the position of the pane
      pane - the pane to add
    • getPanes

      @NotNull @Contract(pure=true) public @NotNull List<Pane> getPanes()
      Description copied from interface: MergedGui
      Gets all the panes in this gui. This includes child panes from other panes.
      Specified by:
      getPanes in interface MergedGui
      Returns:
      all panes
    • getItems

      @NotNull @Contract(pure=true) public @NotNull Collection<GuiItem> getItems()
      Description copied from class: Gui
      Gets all the GuiItem instances in this gui.
      Specified by:
      getItems in interface MergedGui
      Specified by:
      getItems in class Gui
      Returns:
      all gui items
    • createInventory

      @NotNull @Contract(pure=true) public @NotNull Inventory createInventory()
      Description copied from interface: InventoryBased
      Creates a new inventory of the type of the implementing class.
      Specified by:
      createInventory in interface InventoryBased
      Returns:
      the new inventory
    • getRows

      @Contract(pure=true) public int getRows()
      Returns the amount of rows this gui currently has
      Returns:
      the amount of rows
      Since:
      0.8.0
    • getViewerCount

      @Contract(pure=true) public int getViewerCount()
      Description copied from class: Gui
      Gets the count of HumanEntity instances that are currently viewing this GUI.
      Specified by:
      getViewerCount in class Gui
      Returns:
      the count of viewers
    • getViewers

      @NotNull @Contract(pure=true) public @NotNull List<HumanEntity> getViewers()
      Description copied from class: Gui
      Gets a mutable snapshot of the current HumanEntity viewers of this GUI. This is a snapshot (copy) and not a view, therefore modifications aren't visible.
      Specified by:
      getViewers in class Gui
      Returns:
      a snapshot of the current viewers
      See Also:
    • getGuiComponent

      @NotNull @Contract(pure=true) public @NotNull GuiComponent getGuiComponent()
      Description copied from interface: MergedGui
      Gets the gui component for this gui
      Specified by:
      getGuiComponent in interface MergedGui
      Returns:
      the gui component
    • load

      @Nullable @Contract(pure=true) public static @Nullable ChestGui load(@NotNull @NotNull Object instance, @NotNull @NotNull InputStream inputStream, @NotNull @NotNull Plugin plugin)
      Loads a chest gui from an XML file.
      Parameters:
      instance - the instance on which to reference fields and methods
      inputStream - the input stream containing the XML data
      plugin - the plugin that will be the owner of the created gui
      Returns:
      the loaded chest gui
      Since:
      0.10.8
      See Also:
    • load

      @NotNull public static @NotNull ChestGui load(@NotNull @NotNull Object instance, @NotNull @NotNull Element element, @NotNull @NotNull Plugin plugin)
      Loads a chest gui from the specified element, applying code references to the provided instance.
      Parameters:
      instance - the instance on which to reference fields and methods
      element - the element to load the gui from
      plugin - the plugin that will be the owner of the created gui
      Returns:
      the loaded chest gui
      Since:
      0.10.8
      See Also:
    • load

      @Nullable @Contract(pure=true) public static @Nullable ChestGui load(@NotNull @NotNull Object instance, @NotNull @NotNull InputStream inputStream)
      Loads a chest gui from an XML file.
      Parameters:
      instance - the instance on which to reference fields and methods
      inputStream - the input stream containing the XML data
      Returns:
      the loaded chest gui
      Since:
      0.8.0
    • load

      @NotNull public static @NotNull ChestGui load(@NotNull @NotNull Object instance, @NotNull @NotNull Element element)
      Loads a chest gui from the specified element, applying code references to the provided instance.
      Parameters:
      instance - the instance on which to reference fields and methods
      element - the element to load the gui from
      Returns:
      the loaded chest gui
      Since:
      0.8.0
    • isDirtyRows

      public boolean isDirtyRows()