Class NodeBuilder<T extends PermissionHolder>

java.lang.Object
net.lucypoulton.squirtgun.command.node.NodeBuilder<T>
Type Parameters:
T - the target type to build the node for

public class NodeBuilder<T extends PermissionHolder> extends Object
A builder to build a node. The minimum required fields are name and an execute function.
Since:
2.0.0
  • Constructor Details

    • NodeBuilder

      public NodeBuilder()
  • Method Details

    • name

      public NodeBuilder<T> name(@NotNull @NotNull String name)
      Sets this node's name.
      Parameters:
      name - the new name to set
      Returns:
      this
    • description

      public NodeBuilder<T> description(@NotNull @NotNull String description)
      Sets this node's description.
      Parameters:
      description - the new description to set - this should be a short, 1-line sentence
      Returns:
      this
    • condition

      public NodeBuilder<T> condition(@NotNull @NotNull Condition<PermissionHolder,​T> condition)
      Sets this node's required condition.
      Parameters:
      condition - the required condition
      Returns:
      this
    • executes

      public NodeBuilder<T> executes(@NotNull @NotNull Function<CommandContext,​@Nullable net.kyori.adventure.text.Component> executes)
      Sets the function to execute this node.
      Parameters:
      executes - the function. It should return a component to display to the sender. This may be null, in which case nothing will be sent.
      Returns:
      this
    • next

      public NodeBuilder<T> next(@Nullable @Nullable CommandNode<T> next)
      Sets the next node in the chain. Typically you don't need this, the default value of null will suffice.
      Parameters:
      next - a possibly null next node
      Returns:
      this
    • arguments

      public NodeBuilder<T> arguments(@NotNull @NotNull CommandArgument<?>... arguments)
      Adds arguments to this node.
      Parameters:
      arguments - arguments to add, in order, to the list
      Returns:
      this
    • build

      public CommandNode<T> build()
      Builds this node, throwing a NullPointerException if an argument is incorrect or missing.
      Returns:
      a node built from the specified parameters.