Class GuiButtonBuilder

java.lang.Object
github.nighter.smartspawner.api.gui.GuiButtonBuilder

public class GuiButtonBuilder extends Object
Builder for creating GuiButtonData instances programmatically. Used in the SmartSpawner Developer API to define custom GUI buttons.

Example usage:

GuiButtonData button = new GuiButtonBuilder()
    .slot(11)
    .material(Material.CHEST)
    .action("click", "open_storage")
    .build();
  • Constructor Details

    • GuiButtonBuilder

      public GuiButtonBuilder()
  • Method Details

    • buttonType

      public GuiButtonBuilder buttonType(String buttonType)
      Sets the button type identifier.
      Parameters:
      buttonType - the button type (e.g., "slot_11")
      Returns:
      this builder
    • slot

      public GuiButtonBuilder slot(int slot)
      Sets the slot position for this button.
      Parameters:
      slot - the 1-based slot number used by SmartSpawner YAML layouts
      Returns:
      this builder
    • material

      public GuiButtonBuilder material(org.bukkit.Material material)
      Sets the material for this button.
      Parameters:
      material - the Bukkit material
      Returns:
      this builder
    • enabled

      public GuiButtonBuilder enabled(boolean enabled)
      Sets whether this button is enabled.
      Parameters:
      enabled - true if enabled
      Returns:
      this builder
    • condition

      public GuiButtonBuilder condition(String condition)
      Sets a condition for this button to be shown.
      Parameters:
      condition - the condition string (e.g., "sell_integration")
      Returns:
      this builder
    • action

      public GuiButtonBuilder action(String clickType, String action)
      Adds an action for a specific click type.
      Parameters:
      clickType - the click type (e.g., "click", "left_click", "right_click")
      action - the action to perform
      Returns:
      this builder
    • infoButton

      public GuiButtonBuilder infoButton()
      Marks this button as the spawner info button.
      Returns:
      this builder
    • infoButton

      public GuiButtonBuilder infoButton(boolean infoButton)
      Sets whether this button is the spawner info button.
      Parameters:
      infoButton - true if info button
      Returns:
      this builder
    • customTexture

      public GuiButtonBuilder customTexture(String customTexture)
      Sets a custom texture hash for PLAYER_HEAD material.
      Parameters:
      customTexture - the texture hash (without URL prefix)
      Returns:
      this builder
    • cooldownTicks

      public GuiButtonBuilder cooldownTicks(long cooldownTicks)
      Sets a button cooldown in server ticks. Zero disables cooldown.
      Parameters:
      cooldownTicks - cooldown in server ticks
      Returns:
      this builder
    • cooldown

      public GuiButtonBuilder cooldown(String duration)
      Sets a button cooldown using SmartSpawner's config duration format.
      Parameters:
      duration - duration such as "5s", "1m_30s", or a numeric tick value
      Returns:
      this builder
    • sound

      public GuiButtonBuilder sound(String soundName)
      Sets the sound played when the button click is accepted.
      Parameters:
      soundName - Bukkit sound key
      Returns:
      this builder
    • sound

      public GuiButtonBuilder sound(String soundName, float volume, float pitch)
      Sets the sound played when the button click is accepted.
      Parameters:
      soundName - Bukkit sound key
      volume - sound volume
      pitch - sound pitch
      Returns:
      this builder
    • noSound

      public GuiButtonBuilder noSound()
      Removes the configured click sound.
      Returns:
      this builder
    • successSound

      public GuiButtonBuilder successSound(String soundName)
    • successSound

      public GuiButtonBuilder successSound(String soundName, float volume, float pitch)
    • failSound

      public GuiButtonBuilder failSound(String soundName)
    • failSound

      public GuiButtonBuilder failSound(String soundName, float volume, float pitch)
    • sound

      public GuiButtonBuilder sound(String clickType, String soundName, float volume, float pitch)
    • sound

      public GuiButtonBuilder sound(String clickType, String soundName)
    • successSound

      public GuiButtonBuilder successSound(String clickType, String soundName, float volume, float pitch)
    • successSound

      public GuiButtonBuilder successSound(String clickType, String soundName)
    • failSound

      public GuiButtonBuilder failSound(String clickType, String soundName, float volume, float pitch)
    • failSound

      public GuiButtonBuilder failSound(String clickType, String soundName)
    • build

      public GuiButtonData build()
      Builds the GuiButtonData instance.
      Returns:
      the immutable button data