Class ViewConfigBuilder

java.lang.Object
tech.guilhermekaua.spigotboot.inventoryapi.config.ViewConfigBuilder

public final class ViewConfigBuilder extends Object
Fluent, mutable builder for ViewConfig, used in View.onInit; build() validates and freezes the configuration.
  • Constructor Details

    • ViewConfigBuilder

      public ViewConfigBuilder()
  • Method Details

    • title

      @NotNull public @NotNull ViewConfigBuilder title(@NotNull @NotNull String title)
      Sets the inventory title (legacy color codes allowed).
      Parameters:
      title - the title
      Returns:
      this builder
    • rows

      @NotNull public @NotNull ViewConfigBuilder rows(int rows)
      Sets the explicit row count; optional when a layout is present (inferred).
      Parameters:
      rows - the row count, validated to 1-6 at build()
      Returns:
      this builder
    • layout

      @NotNull public @NotNull ViewConfigBuilder layout(@NotNull @NotNull String... rows)
      Sets the layout rows; each row must be non-null and exactly Layout.ROW_WIDTH characters, validated at build().
      Parameters:
      rows - the layout rows
      Returns:
      this builder
    • cancelOnClick

      @NotNull public @NotNull ViewConfigBuilder cancelOnClick(boolean cancel)
      Sets whether clicks are cancelled by default (default true).
      Parameters:
      cancel - the cancel-on-click default
      Returns:
      this builder
    • cancelOnDrag

      @NotNull public @NotNull ViewConfigBuilder cancelOnDrag(boolean cancel)
      Sets whether drags are cancelled by default (default true).
      Parameters:
      cancel - the cancel-on-drag default
      Returns:
      this builder
    • scheduleUpdate

      @NotNull public @NotNull ViewConfigBuilder scheduleUpdate(long intervalTicks)
      Schedules periodic updates; values <= 0 disable scheduling (the default).
      Parameters:
      intervalTicks - the update interval in ticks
      Returns:
      this builder
    • applyPlaceholders

      @NotNull public @NotNull ViewConfigBuilder applyPlaceholders(boolean apply)
      Sets whether placeholders are applied at paint time (default true).
      Parameters:
      apply - the apply-placeholders flag
      Returns:
      this builder
    • build

      @NotNull public @NotNull ViewConfig build()
      Validates and freezes the configuration.
      Returns:
      the immutable config
      Throws:
      ViewConfigurationException - if the title is missing, rows (explicit or inferred from the layout height) are outside 1-6, a layout row is null or not exactly Layout.ROW_WIDTH characters wide, rows and layout are inconsistent, or neither rows nor layout is set