Class GuiBuilder<G extends com.github.stefvanschie.inventoryframework.gui.type.util.Gui,B extends GuiBuilder<G,B>>
- Type Parameters:
G- the type of GUI that this builder createsB- the concrete type of this GUI builder for fluent chaining
- All Implemented Interfaces:
BaseBuilder<B>,Builder<G,B>
- Direct Known Subclasses:
ChestBuilder
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal <P extends com.github.stefvanschie.inventoryframework.pane.Pane>
BAdds a pane to the paginated pane at the specified index.final BaddSingleItem(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 createdOutlinePaneat 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.voidsetDisplayedPage(int index) Sets the displayed page for the GUI using the provided page index and default row settings.abstract voidsetDisplayedPage(int rows, int index) Sets the displayed page for the GUI based on the number of rows and the page index.abstract voidshowGui(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, waitMethods inherited from interface me.croabeast.common.builder.BaseBuilder
instance
-
Field Details
-
pane
protected final com.github.stefvanschie.inventoryframework.pane.PaginatedPane paneThe paginated pane that serves as the container for all added panes. -
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 panepane- the pane to addconsumers- optional consumers to modify the pane- Returns:
- this builder instance for fluent chaining
- Throws:
NullPointerException- if the provided pane isnull
-
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 createdOutlinePaneat 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 itemx- the x-coordinate within the pane where the item will be placedy- the y-coordinate within the pane where the item will be placeditem- the GUI item to addconsumers- 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
-