Class AbstractCommand

java.lang.Object
net.guizhanss.guizhanlib.minecraft.commands.AbstractCommand
Direct Known Subclasses:
BaseCommand, SubCommand

public abstract class AbstractCommand extends Object
This is a node in a command tree. A node can have 0-1 parent node and 0-n child nodes.
Author:
ybw0014
  • Constructor Details

  • Method Details

    • addSubCommand

      @Nonnull public AbstractCommand addSubCommand(@Nonnull SubCommand... subCommands)
      Adds several SubCommand to this node.
      Parameters:
      subCommands - the array of SubCommand to add.
      Returns:
      This AbstractCommand instance, for chaining.
    • hasParent

      public boolean hasParent()
      Check if this node has a parent node.
      Returns:
      Whether this node has a parent node.
    • hasSubCommands

      public boolean hasSubCommands()
      Check if this node has child nodes.
      Returns:
      Whether this node has child nodes.
    • onCommandExecute

      @ParametersAreNonnullByDefault protected final void onCommandExecute(CommandSender sender, Command command, String label, String[] args)
      The general logic of command execution. This does not contain the real logic of the command.
      Parameters:
      sender - The CommandSender of the command.
      args - The arguments of the command.
    • onTabCompleteExecute

      @Nullable @ParametersAreNonnullByDefault protected final List<String> onTabCompleteExecute(CommandSender sender, String[] args)
      The general logic of tab complete execution. This does not contain the real logic of the command.
      Parameters:
      sender - The CommandSender of the command.
      args - The arguments of the command.
    • getFullUsage

      @Nonnull public String getFullUsage(@Nonnull String label)
      Get the full usage of this node.

      Example: /command subcommand <arg1> [arg2]

      Parameters:
      label - The label of the command.
      Returns:
      The full usage of this node.
    • sendHelp

      @ParametersAreNonnullByDefault protected void sendHelp(CommandSender sender, String label)
      Send the help message of this node to the CommandSender.
      Parameters:
      sender - The CommandSender to send the help message to.
      label - The label of the command.
    • onExecute

      @ParametersAreNonnullByDefault public abstract void onExecute(CommandSender sender, String[] args)
    • onTab

      @ParametersAreNonnullByDefault public List<String> onTab(CommandSender sender, String[] args)