Class WbsCommandNode


public abstract class WbsCommandNode extends WbsSubcommand
An implementation of WbsSubcommand that simply passes the command to a given subcommand, including tabbing, or provides default usage messages when no args or incorrect args are given.
  • Constructor Details

    • WbsCommandNode

      public WbsCommandNode(WbsPlugin plugin, String label)
      Parameters:
      plugin - The WbsPlugin
      label - The label for this node
  • Method Details

    • addChild

      public void addChild(WbsSubcommand subcommand)
      Adds a child subcommand
      Parameters:
      subcommand - The child subcommand to pass to if the label is given
    • addChild

      public void addChild(WbsSubcommand subcommand, String permission)
      Adds a child permission and automatically sets the permission for that subcommand
      Parameters:
      subcommand - The child subcommand to pass to if the label is given
      permission - The permission to apply to the child subcommand
    • onCommand

      protected boolean onCommand(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String label, @NotNull @NotNull String[] args, int start)
      Description copied from class: WbsSubcommand
      Run this subcommand for the given sender, starting at arg[start]. When this is called, the permission has already been checked.
      Overrides:
      onCommand in class WbsSubcommand
      Parameters:
      sender - The sender that ran the command
      label - The alias used to run this command
      args - The arguments provided
      Returns:
      false if the command failed unexpectedly, true otherwise
    • onCommand

      protected final boolean onCommand(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String label, @NotNull @NotNull String[] args)
      Theoretically should never be called, only being implemented here since the start version is implemented, and implementing subclasses shouldn't be able to implement this (as they might expect it to be called).
      Overrides:
      onCommand in class WbsSubcommand
      Parameters:
      sender - The sender that ran the command
      label - The alias used to run this command
      args - The arguments provided
      Returns:
      false if the command failed unexpectedly, true otherwise
    • onCommandNoArgs

      protected boolean onCommandNoArgs(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String label, @NotNull @NotNull String[] args, int start)
    • getTabCompletions

      public List<String> getTabCompletions(@NotNull @NotNull org.bukkit.command.CommandSender sender, @NotNull @NotNull String label, @NotNull @NotNull String[] args, int start)
      Overrides:
      getTabCompletions in class WbsSubcommand
    • getSubcommandLabels

      public List<String> getSubcommandLabels(org.bukkit.command.CommandSender sender)
      Gets a list of all labels for subcommands usable by the given sender
      Parameters:
      sender - The sender to filter by
      Returns:
      The list of labels for subcommands usable by the sender
    • getArgLength

      protected int getArgLength()
      Returns:
      The number of arguments this node will process before handing off to the child