Class SubcommandNode<T extends me.lucyy.squirtgun.platform.audience.PermissionHolder>
- java.lang.Object
-
- me.lucyy.squirtgun.command.node.AbstractNode<T>
-
- me.lucyy.squirtgun.command.node.subcommand.SubcommandNode<T>
-
- All Implemented Interfaces:
CommandNode<T>
public class SubcommandNode<T extends me.lucyy.squirtgun.platform.audience.PermissionHolder> extends AbstractNode<T>
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
Constructors Modifier Constructor Description protectedSubcommandNode(@NotNull java.lang.String name, @NotNull java.lang.String description, @Nullable java.lang.String permission, @NotNull CommandNode<T>... childNodes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description @Nullable net.kyori.adventure.text.Componentexecute(CommandContext<T> context)Execute this node.@NotNull java.util.List<CommandArgument<?>>getArguments()Gets this command's arguments.@Nullable CommandNode<T>getFallbackNode()Gets the fallback node.java.util.Set<? extends CommandNode<T>>getNodes()Gets the child nodes that this node holds.@Nullable CommandNode<T>next(CommandContext<T> context)Returns the node following this node.static <T extends me.lucyy.squirtgun.platform.audience.PermissionHolder>
SubcommandNode<T>withBasicHelp(java.lang.String name, java.lang.String description, @Nullable java.lang.String permission, @NotNull CommandNode<T>... childNodes)Creates a node with a basic help node.static <T extends me.lucyy.squirtgun.platform.audience.PermissionHolder>
SubcommandNode<T>withFallback(java.lang.String name, java.lang.String description, @Nullable java.lang.String permission, @NotNull CommandNode<T> fallback, @NotNull CommandNode<T>... childNodes)Creates a node with a custom default node.static <T extends me.lucyy.squirtgun.platform.audience.PermissionHolder>
SubcommandNode<T>withHelp(java.lang.String name, java.lang.String description, @Nullable java.lang.String permission, @NotNull CommandNode<T>... childNodes)Creates a node with an advanced help node.-
Methods inherited from class me.lucyy.squirtgun.command.node.AbstractNode
getDescription, getName, getPermission
-
-
-
-
Constructor Detail
-
SubcommandNode
@SafeVarargs protected SubcommandNode(@NotNull @NotNull java.lang.String name, @NotNull @NotNull java.lang.String description, @Nullable @Nullable java.lang.String permission, @NotNull @NotNull CommandNode<T>... childNodes)- Parameters:
name- this node's name.permission- the permission needed to execute this node. May be null if none is required.childNodes- the child nodes
-
-
Method Detail
-
withHelp
@SafeVarargs public static <T extends me.lucyy.squirtgun.platform.audience.PermissionHolder> SubcommandNode<T> withHelp(java.lang.String name, java.lang.String description, @Nullable @Nullable java.lang.String permission, @NotNull @NotNull CommandNode<T>... childNodes)
Creates a node with an advanced help node.- Parameters:
name- this node's namedescription- this node's descriptionpermission- the permission needed to execute this node. May be null if none is requiredchildNodes- the child nodes- Returns:
- a new SubcommandNode
-
withFallback
@SafeVarargs public static <T extends me.lucyy.squirtgun.platform.audience.PermissionHolder> SubcommandNode<T> withFallback(java.lang.String name, java.lang.String description, @Nullable @Nullable java.lang.String permission, @NotNull @NotNull CommandNode<T> fallback, @NotNull @NotNull CommandNode<T>... childNodes)
Creates a node with a custom default node.- Parameters:
name- this node's namedescription- this node's descriptionpermission- the permission needed to execute this node. May be null if none is requiredfallback- the node to use if no valid subcommand is specifiedchildNodes- the child nodes- Returns:
- a new SubcommandNode
-
withBasicHelp
@SafeVarargs public static <T extends me.lucyy.squirtgun.platform.audience.PermissionHolder> SubcommandNode<T> withBasicHelp(java.lang.String name, java.lang.String description, @Nullable @Nullable java.lang.String permission, @NotNull @NotNull CommandNode<T>... childNodes)
Creates a node with a basic help node.- Parameters:
name- this node's namedescription- this node's descriptionpermission- the permission needed to execute this node. May be null if none is requiredchildNodes- the child nodes- Returns:
- a new SubcommandNode
-
getNodes
public java.util.Set<? extends CommandNode<T>> getNodes()
Gets the child nodes that this node holds.
-
getFallbackNode
@Nullable public @Nullable CommandNode<T> getFallbackNode()
Gets the fallback node.
-
getArguments
@NotNull public @NotNull java.util.List<CommandArgument<?>> getArguments()
Description copied from interface:CommandNodeGets this command's arguments. By default, returns an empty list.
-
next
@Nullable public @Nullable CommandNode<T> next(CommandContext<T> context)
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
@Nullable public @Nullable net.kyori.adventure.text.Component execute(CommandContext<T> context)
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
-
-