java.lang.Object
net.lucypoulton.squirtgun.command.node.AbstractNode<PermissionHolder>
net.lucypoulton.squirtgun.command.node.subcommand.SubcommandNode
All Implemented Interfaces:
CommandNode<PermissionHolder>

public class SubcommandNode extends AbstractNode<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 Details

    • SubcommandNode

      protected SubcommandNode(@NotNull @NotNull String name, @NotNull @NotNull String description, Condition<PermissionHolder,?> condition, @NotNull @NotNull CommandNode<?>... childNodes)
      Parameters:
      name - this node's name
      condition - the condition needed to execute this node
      childNodes - 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 name
      description - this node's description
      condition - the condition needed to execute this node
      childNodes - 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 name
      description - this node's description
      condition - the condition needed to execute this node
      fallback - the node to use if no valid subcommand is specified
      childNodes - 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 name
      description - this node's description
      condition - the condition needed to execute this node
      childNodes - the child nodes
      Returns:
      a new SubcommandNode
    • getNodes

      public Set<CommandNode<?>> getNodes()
      Gets the child nodes that this node holds.
    • getFallbackNode

      @Nullable public @Nullable CommandNode<?> getFallbackNode()
      Gets the fallback node.
    • getArguments

      @NotNull public @NotNull List<CommandArgument<?>> getArguments()
      Description copied from interface: CommandNode
      Gets this command's arguments. By default, returns an empty list.
    • next

      @Nullable public @Nullable CommandNode<? extends PermissionHolder> next(CommandContext context)
      Description copied from interface: CommandNode
      Returns 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 context)
      Description copied from interface: CommandNode
      Execute 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