Package me.croabeast.common.gui
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:
-
Field Summary
Fields inherited from class me.croabeast.common.gui.PaneBuilder
value -
Method Summary
Modifier and TypeMethodDescription@NotNull ButtonBuilderinstance()Returns this instance ofButtonBuilder.static ButtonBuilderof(int x, int y, boolean value) Creates a newButtonBuilderusing the specified x and y coordinates and initial value.static ButtonBuilderof(com.github.stefvanschie.inventoryframework.pane.util.Slot slot, boolean value) Creates a newButtonBuilderusing the specified slot and initial value.@NotNull ButtonBuildersetItem(com.github.stefvanschie.inventoryframework.gui.GuiItem item, boolean isEnabled) Sets the GUI item for the button.Methods inherited from class me.croabeast.common.gui.PaneBuilder
compare, setAction, setAction
-
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
isEnabledistrue, the provided item is set as the enabled item; otherwise, it is set as the disabled item.- Parameters:
item- theGuiItemto setisEnabled- flag indicating whether to set the item as enabled or disabled- Returns:
- this
ButtonBuilderinstance for chaining
-
instance
Returns this instance ofButtonBuilder.- Returns:
- this builder instance for fluent chaining
-
of
public static ButtonBuilder of(com.github.stefvanschie.inventoryframework.pane.util.Slot slot, boolean value) Creates a newButtonBuilderusing the specified slot and initial value.- Parameters:
slot- the slot where the button will be placedvalue- the initial toggle state- Returns:
- a new
ButtonBuilderinstance
-
of
Creates a newButtonBuilderusing the specified x and y coordinates and initial value.- Parameters:
x- the x-coordinate of the sloty- the y-coordinate of the slotvalue- the initial toggle state- Returns:
- a new
ButtonBuilderinstance
-