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
A builder to build a node. The minimum required fields are name and an execute function.
- Since:
- 2.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionarguments(@NotNull CommandArgument<?>... arguments)Adds arguments to this node.build()Builds this node, throwing aNullPointerExceptionif an argument is incorrect or missing.condition(@NotNull Condition<PermissionHolder,T> condition)Sets this node's required condition.description(@NotNull String description)Sets this node's description.executes(@NotNull Function<CommandContext,@Nullable net.kyori.adventure.text.Component> executes)Sets the function to execute this node.Sets this node's name.next(@Nullable CommandNode<T> next)Sets the next node in the chain.
-
Constructor Details
-
NodeBuilder
public NodeBuilder()
-
-
Method Details
-
name
Sets this node's name.- Parameters:
name- the new name to set- Returns:
- this
-
description
Sets this node's description.- Parameters:
description- the new description to set - this should be a short, 1-line sentence- Returns:
- this
-
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
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
Adds arguments to this node.- Parameters:
arguments- arguments to add, in order, to the list- Returns:
- this
-
build
Builds this node, throwing aNullPointerExceptionif an argument is incorrect or missing.- Returns:
- a node built from the specified parameters.
-