Class SubcommandNode
java.lang.Object
net.lucypoulton.squirtgun.command.node.AbstractNode<PermissionHolder>
net.lucypoulton.squirtgun.command.node.subcommand.SubcommandNode
- All Implemented Interfaces:
CommandNode<PermissionHolder>
A node that tab completes and acts as a "splitter" for other nodes.
As per the name, it can be used to create subcommands.
- Since:
- 2.0.0
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSubcommandNode(@NotNull String name, @NotNull String description, Condition<PermissionHolder,?> condition, @NotNull CommandNode<?>... childNodes) -
Method Summary
Modifier and TypeMethodDescription@Nullable net.kyori.adventure.text.Componentexecute(CommandContext context)Execute this node.@NotNull List<CommandArgument<?>>Gets this command's arguments.@Nullable CommandNode<?>Gets the fallback node.Set<CommandNode<?>>getNodes()Gets the child nodes that this node holds.@Nullable CommandNode<? extends PermissionHolder>next(CommandContext context)Returns the node following this node.static SubcommandNodewithBasicHelp(String name, String description, Condition<PermissionHolder,?> condition, @NotNull CommandNode<?>... childNodes)Creates a node with a basic help node.static SubcommandNodewithFallback(String name, String description, Condition<PermissionHolder,?> condition, @NotNull CommandNode<?> fallback, @NotNull CommandNode<?>... childNodes)Creates a node with a custom default node.static SubcommandNodewithHelp(String name, String description, Condition<PermissionHolder,?> condition, @NotNull CommandNode<?>... childNodes)Creates a node with an advanced help node.Methods inherited from class net.lucypoulton.squirtgun.command.node.AbstractNode
getCondition, getDescription, getNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.lucypoulton.squirtgun.command.node.CommandNode
withExtraCondition
-
Constructor Details
-
SubcommandNode
protected SubcommandNode(@NotNull @NotNull String name, @NotNull @NotNull String description, Condition<PermissionHolder,?> condition, @NotNull @NotNull CommandNode<?>... childNodes)- Parameters:
name- this node's namecondition- the condition needed to execute this nodechildNodes- the child nodes
-
-
Method Details
-
withHelp
public static SubcommandNode withHelp(String name, String description, Condition<PermissionHolder,?> condition, @NotNull @NotNull CommandNode<?>... childNodes)Creates a node with an advanced help node.- Parameters:
name- this node's namedescription- this node's descriptioncondition- the condition needed to execute this nodechildNodes- the child nodes- Returns:
- a new SubcommandNode
-
withFallback
public static SubcommandNode withFallback(String name, String description, Condition<PermissionHolder,?> condition, @NotNull @NotNull CommandNode<?> fallback, @NotNull @NotNull CommandNode<?>... childNodes)Creates a node with a custom default node.- Parameters:
name- this node's namedescription- this node's descriptioncondition- the condition needed to execute this nodefallback- the node to use if no valid subcommand is specifiedchildNodes- the child nodes- Returns:
- a new SubcommandNode
-
withBasicHelp
public static SubcommandNode withBasicHelp(String name, String description, Condition<PermissionHolder,?> condition, @NotNull @NotNull CommandNode<?>... childNodes)Creates a node with a basic help node.- Parameters:
name- this node's namedescription- this node's descriptioncondition- the condition needed to execute this nodechildNodes- the child nodes- Returns:
- a new SubcommandNode
-
getNodes
Gets the child nodes that this node holds. -
getFallbackNode
Gets the fallback node. -
getArguments
Description copied from interface:CommandNodeGets this command's arguments. By default, returns an empty list. -
next
Description copied from interface:CommandNodeReturns the node following this node.- Returns:
- the next node in the chain, or if this is the end of the chain, null
-
execute
Description copied from interface:CommandNodeExecute this node. This will only be executed if there are no further nodes in the chain.- Parameters:
context- the context that this command was executed in- Returns:
- a component to optionally
-