Class ButtonBuilder

java.lang.Object
me.croabeast.common.gui.PaneBuilder<com.github.stefvanschie.inventoryframework.pane.component.ToggleButton,ButtonBuilder>
me.croabeast.common.gui.ButtonBuilder
All Implemented Interfaces:
BaseBuilder<ButtonBuilder>, Builder<com.github.stefvanschie.inventoryframework.pane.component.ToggleButton,ButtonBuilder>

public final class ButtonBuilder extends PaneBuilder<com.github.stefvanschie.inventoryframework.pane.component.ToggleButton,ButtonBuilder>
A builder for creating and configuring a toggle button in a GUI.

The ButtonBuilder simplifies the process of creating a toggle button using an ToggleButton wrapped in a PaneBuilder. It provides methods to set the enabled and disabled items, as well as convenient factory methods to create a new builder instance from a Slot or by x and y coordinates.

Example usage:


 ButtonBuilder button = ButtonBuilder.of(Slot.fromXY(3, 2), true)
     .setItem(new GuiItem(myItemStack), true);
 

See Also:
  • Method Details

    • setItem

      @NotNull public @NotNull ButtonBuilder setItem(com.github.stefvanschie.inventoryframework.gui.GuiItem item, boolean isEnabled)
      Sets the GUI item for the button.

      If isEnabled is true, the provided item is set as the enabled item; otherwise, it is set as the disabled item.

      Parameters:
      item - the GuiItem to set
      isEnabled - flag indicating whether to set the item as enabled or disabled
      Returns:
      this ButtonBuilder instance for chaining
    • instance

      @NotNull public @NotNull ButtonBuilder instance()
      Returns this instance of ButtonBuilder.
      Returns:
      this builder instance for fluent chaining
    • of

      public static ButtonBuilder of(com.github.stefvanschie.inventoryframework.pane.util.Slot slot, boolean value)
      Creates a new ButtonBuilder using the specified slot and initial value.
      Parameters:
      slot - the slot where the button will be placed
      value - the initial toggle state
      Returns:
      a new ButtonBuilder instance
    • of

      public static ButtonBuilder of(int x, int y, boolean value)
      Creates a new ButtonBuilder using the specified x and y coordinates and initial value.
      Parameters:
      x - the x-coordinate of the slot
      y - the y-coordinate of the slot
      value - the initial toggle state
      Returns:
      a new ButtonBuilder instance