Class Gui.Builder

java.lang.Object
com.github.darksoulq.abyssallib.world.gui.Gui.Builder
Enclosing class:
Gui

public static class Gui.Builder extends Object
A fluent builder for creating Gui configurations.
  • 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 type
      title - the title component
  • Method Details

    • set

      public Gui.Builder set(SlotPosition pos, GuiElement element)
      Assigns an element to a specific slot position.
      Parameters:
      pos - the position in the top or bottom segment
      element - the element to render
      Returns:
      this builder
    • set

      public Gui.Builder set(Iterable<SlotPosition> positions, GuiElement element)
      Assigns an element to multiple slot positions.
      Parameters:
      positions - the collection of positions
      element - the element to render
      Returns:
      this builder
    • fill

      public Gui.Builder fill(GuiView.Segment segment, int startSlot, int endSlot, GuiElement element)
      Fills a specific range of slots within a segment with the given element.
      Parameters:
      segment - the inventory segment
      startSlot - 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 structure
      structure - the structure array containing elements
      inventoryWidth - 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)
      Parameters:
      segment - the inventory segment
      startSlot - the top-left slot index
      rows - the height of the rectangle in rows
      cols - the width of the rectangle in columns
      maxRows - the maximum number of rows in the inventory
      maxCols - the maximum number of columns in the inventory
      element - the element to render
      Returns:
      this builder
    • fillRow

      public Gui.Builder fillRow(GuiView.Segment segment, int startSlot, int length, int maxCols, GuiElement element)
      Parameters:
      segment - the inventory segment
      startSlot - the slot index where the row begins
      length - the number of slots in the row
      maxCols - the maximum number of columns in the inventory
      element - 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)
      Parameters:
      segment - the inventory segment
      startSlot - the slot index where the column begins
      step - the vertical increment between slots
      length - the number of slots in the column
      maxRows - the maximum number of rows in the inventory
      maxCols - the maximum number of columns in the inventory
      element - 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)
      Parameters:
      segment - the inventory segment
      startSlot - the top-left slot index of the grid
      rows - the number of rows in the grid
      cols - the number of columns in the grid
      maxRows - the maximum number of rows in the inventory
      maxCols - the maximum number of columns in the inventory
      element - the element to render
      Returns:
      this builder
    • addLayer

      public Gui.Builder addLayer(GuiLayer layer)
      Adds a visual layer to the GUI.
      Parameters:
      layer - the layer instance
      Returns:
      this builder
    • onTick

      public Gui.Builder onTick(Consumer<GuiView> tick)
      Adds a logic handler to be executed every tick.
      Parameters:
      tick - the tick consumer
      Returns:
      this builder
    • onOpen

      public Gui.Builder onOpen(Consumer<GuiView> handler)
      Sets the handler for when the GUI is opened.
      Parameters:
      handler - the open consumer
      Returns:
      this builder
    • onClose

      public Gui.Builder onClose(Consumer<GuiView> handler)
      Sets the handler for when the GUI is closed.
      Parameters:
      handler - the close consumer
      Returns:
      this builder
    • addFlag

      public Gui.Builder addFlag(GuiFlag flag)
      Adds a behavioral flag to the GUI.
      Parameters:
      flag - the flag to add
      Returns:
      this builder
    • addFlags

      public Gui.Builder addFlags(GuiFlag... flags)
      Adds multiple behavioral flags to the GUI.
      Parameters:
      flags - the flags to add
      Returns:
      this builder
    • tickInterval

      public Gui.Builder tickInterval(int interval)
      Sets the tick interval between GuiView#render calls.
      Parameters:
      interval - The tick interval.
      Returns:
      This builder
    • build

      public Gui build()
      Constructs the Gui instance from the builder configuration.
      Returns:
      the built Gui