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 built
B - 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
    Modifier and Type
    Field
    Description
    protected final P
    The underlying pane instance that is being built and configured.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    compare(P pane)
    Compares this builder's underlying pane with another pane by comparing their UUIDs.
    setAction(Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
    Sets the action to be executed when the pane is clicked.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface me.croabeast.common.builder.BaseBuilder

    instance

    Methods inherited from interface me.croabeast.common.builder.Builder

    getValue, modify
  • Field Details

    • value

      protected final P extends com.github.stefvanschie.inventoryframework.pane.Pane value
      The underlying pane instance that is being built and configured.
  • Constructor Details

    • PaneBuilder

      public PaneBuilder()
  • Method Details

    • setAction

      @NotNull public B setAction(Consumer<org.bukkit.event.inventory.InventoryClickEvent> consumer)
      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

      public boolean compare(P pane)
      Compares this builder's underlying pane with another pane by comparing their UUIDs.
      Parameters:
      pane - the pane to compare with
      Returns:
      true if both panes have the same UUID; false otherwise