Package me.croabeast.common.gui
Class PaneBuilder<P extends com.github.stefvanschie.inventoryframework.pane.Pane,B extends PaneBuilder<P,B>>
java.lang.Object
me.croabeast.common.gui.PaneBuilder<P,B>
- Type Parameters:
P- the type of the pane being builtB- the concrete type of this builder for fluent method chaining
- All Implemented Interfaces:
BaseBuilder<B>,Builder<P,B>
- Direct Known Subclasses:
ButtonBuilder
public abstract class PaneBuilder<P extends com.github.stefvanschie.inventoryframework.pane.Pane,B extends PaneBuilder<P,B>>
extends Object
implements Builder<P,B>
An abstract builder for constructing and configuring
Pane objects in a fluent manner.
The PaneBuilder simplifies the process of setting up and modifying panes used in GUI frameworks,
allowing the registration of click actions and other pane-specific configurations. It implements the Builder
interface to provide a fluent API for chaining modifications to the underlying pane.
Example usage:
Pane myPane = ...; // obtain or create a pane instance
PaneBuilder<Pane, ?> builder = MyPaneBuilder.of(myPane);
builder.setAction(event -> {
// Handle click event
}).getValue(); // returns the configured pane
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanCompares this builder's underlying pane with another pane by comparing their UUIDs.Sets the action to be executed when the pane is clicked.Sets the click action for the pane using a function that maps the pane to a click event consumer.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface me.croabeast.common.builder.BaseBuilder
instance
-
Field Details
-
value
The underlying pane instance that is being built and configured.
-
-
Constructor Details
-
PaneBuilder
public PaneBuilder()
-
-
Method Details
-
setAction
Sets the action to be executed when the pane is clicked.The provided consumer will be registered as the click handler for the pane.
- Parameters:
consumer- the click event consumer to set- Returns:
- the current builder instance for fluent chaining
-
setAction
@NotNull public B setAction(Function<P, Consumer<org.bukkit.event.inventory.InventoryClickEvent>> function) Sets the click action for the pane using a function that maps the pane to a click event consumer.This overload allows for dynamic determination of the click action based on the current state of the pane.
- Parameters:
function- a function that takes the pane and returns a click event consumer- Returns:
- the current builder instance for fluent chaining
-
compare
Compares this builder's underlying pane with another pane by comparing their UUIDs.- Parameters:
pane- the pane to compare with- Returns:
trueif both panes have the same UUID;falseotherwise
-