Class GuiBuilder<G extends com.github.stefvanschie.inventoryframework.gui.type.util.Gui,B extends GuiBuilder<G,B>>

java.lang.Object
me.croabeast.common.gui.GuiBuilder<G,B>
Type Parameters:
G - the type of GUI that this builder creates
B - the concrete type of this GUI builder for fluent chaining
All Implemented Interfaces:
BaseBuilder<B>, Builder<G,B>
Direct Known Subclasses:
ChestBuilder

public abstract class GuiBuilder<G extends com.github.stefvanschie.inventoryframework.gui.type.util.Gui,B extends GuiBuilder<G,B>> extends Object implements Builder<G,B>
An abstract builder for creating and managing GUIs with paginated panes.

The GuiBuilder provides a fluent API to build complex GUIs by allowing the addition of panes and items in a paginated layout. It implements Builder to allow chainable modifications to the underlying GUI value.

Typical usage involves adding panes, adding individual items to specific panes, and displaying the GUI to a human entity.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final com.github.stefvanschie.inventoryframework.pane.PaginatedPane
    The paginated pane that serves as the container for all added panes.
    protected final G
    The underlying GUI object managed by this builder.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final <P extends com.github.stefvanschie.inventoryframework.pane.Pane>
    B
    addPane(int index, P pane, Consumer<P>... consumers)
    Adds a pane to the paginated pane at the specified index.
    final B
    addSingleItem(int index, int x, int y, com.github.stefvanschie.inventoryframework.gui.GuiItem item, Consumer<com.github.stefvanschie.inventoryframework.pane.OutlinePane>... consumers)
    Adds a single GUI item to a newly created OutlinePane at the specified position and adds it to the paginated pane at the given index.
    final @NotNull Collection<com.github.stefvanschie.inventoryframework.pane.Pane>
    getPanes(int index)
    Retrieves all panes at the specified index within the paginated pane.
    void
    setDisplayedPage(int index)
    Sets the displayed page for the GUI using the provided page index and default row settings.
    abstract void
    setDisplayedPage(int rows, int index)
    Sets the displayed page for the GUI based on the number of rows and the page index.
    abstract void
    showGui(org.bukkit.entity.HumanEntity entity)
    Displays the constructed GUI to the specified human entity.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface me.croabeast.common.builder.BaseBuilder

    instance

    Methods inherited from interface me.croabeast.common.builder.Builder

    getValue, modify
  • Field Details

    • pane

      protected final com.github.stefvanschie.inventoryframework.pane.PaginatedPane pane
      The paginated pane that serves as the container for all added panes.
    • value

      protected final G extends com.github.stefvanschie.inventoryframework.gui.type.util.Gui value
      The underlying GUI object managed by this builder.
  • Constructor Details

    • GuiBuilder

      public GuiBuilder()
  • Method Details

    • addPane

      @SafeVarargs public final <P extends com.github.stefvanschie.inventoryframework.pane.Pane> B addPane(int index, P pane, Consumer<P>... consumers)
      Adds a pane to the paginated pane at the specified index.

      Optional consumers can be provided to further configure the pane before it is added.

      Type Parameters:
      P - the type of the pane being added
      Parameters:
      index - the index at which to add the pane
      pane - the pane to add
      consumers - optional consumers to modify the pane
      Returns:
      this builder instance for fluent chaining
      Throws:
      NullPointerException - if the provided pane is null
    • addSingleItem

      @SafeVarargs public final B addSingleItem(int index, int x, int y, com.github.stefvanschie.inventoryframework.gui.GuiItem item, Consumer<com.github.stefvanschie.inventoryframework.pane.OutlinePane>... consumers)
      Adds a single GUI item to a newly created OutlinePane at the specified position and adds it to the paginated pane at the given index.

      Optional consumers can be provided to further configure the outline pane.

      Parameters:
      index - the index at which to add the pane containing the item
      x - the x-coordinate within the pane where the item will be placed
      y - the y-coordinate within the pane where the item will be placed
      item - the GUI item to add
      consumers - optional consumers to modify the outline pane
      Returns:
      this builder instance for fluent chaining
    • getPanes

      @NotNull public final @NotNull Collection<com.github.stefvanschie.inventoryframework.pane.Pane> getPanes(int index)
      Retrieves all panes at the specified index within the paginated pane.
      Parameters:
      index - the index from which to retrieve panes
      Returns:
      a collection of panes at the given index
    • setDisplayedPage

      public abstract void setDisplayedPage(int rows, int index)
      Sets the displayed page for the GUI based on the number of rows and the page index.

      This abstract method should be implemented to adjust the GUI display according to the specific layout.

      Parameters:
      rows - the number of rows in the display (or -1 to use a default setting)
      index - the index of the page to display
    • setDisplayedPage

      public void setDisplayedPage(int index)
      Sets the displayed page for the GUI using the provided page index and default row settings.
      Parameters:
      index - the index of the page to display
    • showGui

      public abstract void showGui(org.bukkit.entity.HumanEntity entity)
      Displays the constructed GUI to the specified human entity.

      This abstract method should be implemented to handle the specifics of how the GUI is shown to the player, including any necessary event handling or animations.

      Parameters:
      entity - the human entity (typically a player) to display the GUI to