Package me.lucyy.squirtgun.command.node
Class NodeBuilder<T extends me.lucyy.squirtgun.platform.PermissionHolder>
java.lang.Object
me.lucyy.squirtgun.command.node.NodeBuilder<T>
- Type Parameters:
T- the type to expect from the command context
public class NodeBuilder<T extends me.lucyy.squirtgun.platform.PermissionHolder>
extends java.lang.Object
A builder to build a node. The minimum required fields are name and an execute function.
- Since:
- 2.0.0
-
Constructor Summary
Constructors Constructor Description NodeBuilder() -
Method Summary
Modifier and Type Method Description NodeBuilder<T>arguments(@NotNull CommandArgument<?>... arguments)Adds arguments to this node.CommandNode<T>build()Builds this node, throwing aNullPointerExceptionif an argument is incorrect or missing.NodeBuilder<T>description(@NotNull java.lang.String description)Sets this node's description.NodeBuilder<T>executes(@NotNull java.util.function.Function<CommandContext<T>,@Nullable net.kyori.adventure.text.Component> executes)Sets the function to execute this node.NodeBuilder<T>name(@NotNull java.lang.String name)Sets this node's name.NodeBuilder<T>next(@Nullable CommandNode<T> next)Sets the next node in the chain.NodeBuilder<T>permission(@Nullable java.lang.String permission)Sets this node's required permission.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
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
-
permission
Sets this node's required permission.- Parameters:
permission- the required permission or null if none is needed- Returns:
- this
-
executes
public NodeBuilder<T> executes(@NotNull @NotNull java.util.function.Function<CommandContext<T>,@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.
-