Class Gui.Builder
java.lang.Object
com.github.darksoulq.abyssallib.world.gui.Gui.Builder
- Enclosing class:
Gui
A fluent builder for creating Gui configurations.
-
Constructor Summary
ConstructorsConstructorDescriptionBuilder(org.bukkit.inventory.MenuType menuType, net.kyori.adventure.text.Component title) Constructs the builder with required fields. -
Method Summary
Modifier and TypeMethodDescriptionAdds a behavioral flag to the GUI.Adds multiple behavioral flags to the GUI.Adds a visual layer to the GUI.build()Constructs the Gui instance from the builder configuration.fill(GuiView.Segment segment, int startSlot, int endSlot, GuiElement element) Fills a specific range of slots within a segment with the given element.fillBorder(GuiView.Segment segment, int startSlot, int rows, int cols, int maxRows, int maxCols, GuiElement element) Fills a rectangular border usingSlotUtil.border(GuiView.Segment, int, int, int, int, int).fillColumn(GuiView.Segment segment, int startSlot, int step, int length, int maxRows, int maxCols, GuiElement element) Fills a column usingSlotUtil.column(GuiView.Segment, int, int, int, int, int).fillGrid(GuiView.Segment segment, int startSlot, int rows, int cols, int maxRows, int maxCols, GuiElement element) Fills a solid grid usingSlotUtil.grid(GuiView.Segment, int, int, int, int, int).fillRow(GuiView.Segment segment, int startSlot, int length, int maxCols, GuiElement element) Fills a row usingSlotUtil.row(GuiView.Segment, int, int, int).Sets the handler for when the GUI is closed.Sets the handler for when the GUI is opened.Adds a logic handler to be executed every tick.set(SlotPosition pos, GuiElement element) Assigns an element to a specific slot position.set(Iterable<SlotPosition> positions, GuiElement element) Assigns an element to multiple slot positions.structure(SlotPosition origin, StructureArray<? extends GuiElement> structure, int inventoryWidth) Applies a StructureArray of GuiElements to the GUI.tickInterval(int interval) Sets the tick interval betweenGuiView#rendercalls.
-
Constructor Details
-
Builder
public Builder(org.bukkit.inventory.MenuType menuType, net.kyori.adventure.text.Component title) Constructs the builder with required fields.- Parameters:
menuType- the menu typetitle- the title component
-
-
Method Details
-
set
Assigns an element to a specific slot position.- Parameters:
pos- the position in the top or bottom segmentelement- the element to render- Returns:
- this builder
-
set
Assigns an element to multiple slot positions.- Parameters:
positions- the collection of positionselement- the element to render- Returns:
- this builder
-
fill
Fills a specific range of slots within a segment with the given element.- Parameters:
segment- the inventory segmentstartSlot- the starting slot index (inclusive)endSlot- the ending slot index (exclusive)element- the element to render- Returns:
- this builder
-
structure
public Gui.Builder structure(SlotPosition origin, StructureArray<? extends GuiElement> structure, int inventoryWidth) Applies a StructureArray of GuiElements to the GUI.- Parameters:
origin- the starting position (top-left) for the structurestructure- the structure array containing elementsinventoryWidth- the maximum width of the inventory segment- Returns:
- this builder
-
fillBorder
public Gui.Builder fillBorder(GuiView.Segment segment, int startSlot, int rows, int cols, int maxRows, int maxCols, GuiElement element) Fills a rectangular border usingSlotUtil.border(GuiView.Segment, int, int, int, int, int).- Parameters:
segment- the inventory segmentstartSlot- the top-left slot indexrows- the height of the rectangle in rowscols- the width of the rectangle in columnsmaxRows- the maximum number of rows in the inventorymaxCols- the maximum number of columns in the inventoryelement- the element to render- Returns:
- this builder
-
fillRow
public Gui.Builder fillRow(GuiView.Segment segment, int startSlot, int length, int maxCols, GuiElement element) Fills a row usingSlotUtil.row(GuiView.Segment, int, int, int).- Parameters:
segment- the inventory segmentstartSlot- the slot index where the row beginslength- the number of slots in the rowmaxCols- the maximum number of columns in the inventoryelement- the element to render- Returns:
- this builder
-
fillColumn
public Gui.Builder fillColumn(GuiView.Segment segment, int startSlot, int step, int length, int maxRows, int maxCols, GuiElement element) Fills a column usingSlotUtil.column(GuiView.Segment, int, int, int, int, int).- Parameters:
segment- the inventory segmentstartSlot- the slot index where the column beginsstep- the vertical increment between slotslength- the number of slots in the columnmaxRows- the maximum number of rows in the inventorymaxCols- the maximum number of columns in the inventoryelement- the element to render- Returns:
- this builder
-
fillGrid
public Gui.Builder fillGrid(GuiView.Segment segment, int startSlot, int rows, int cols, int maxRows, int maxCols, GuiElement element) Fills a solid grid usingSlotUtil.grid(GuiView.Segment, int, int, int, int, int).- Parameters:
segment- the inventory segmentstartSlot- the top-left slot index of the gridrows- the number of rows in the gridcols- the number of columns in the gridmaxRows- the maximum number of rows in the inventorymaxCols- the maximum number of columns in the inventoryelement- the element to render- Returns:
- this builder
-
addLayer
Adds a visual layer to the GUI.- Parameters:
layer- the layer instance- Returns:
- this builder
-
onTick
Adds a logic handler to be executed every tick.- Parameters:
tick- the tick consumer- Returns:
- this builder
-
onOpen
Sets the handler for when the GUI is opened.- Parameters:
handler- the open consumer- Returns:
- this builder
-
onClose
Sets the handler for when the GUI is closed.- Parameters:
handler- the close consumer- Returns:
- this builder
-
addFlag
Adds a behavioral flag to the GUI.- Parameters:
flag- the flag to add- Returns:
- this builder
-
addFlags
Adds multiple behavioral flags to the GUI.- Parameters:
flags- the flags to add- Returns:
- this builder
-
tickInterval
Sets the tick interval betweenGuiView#rendercalls.- Parameters:
interval- The tick interval.- Returns:
- This builder
-
build
Constructs the Gui instance from the builder configuration.- Returns:
- the built Gui
-