Class ParentCommand

java.lang.Object
com.booksaw.betterTeams.commands.SubCommand
com.booksaw.betterTeams.commands.ParentCommand
Direct Known Subclasses:
PermissionParentCommand

public class ParentCommand extends SubCommand
This is used for any parent commands across the system
Author:
booksaw
  • Constructor Details

    • ParentCommand

      public ParentCommand(String command)
      Creates a new parent command with a set of sub commands
      Parameters:
      command - the command which will be defaulted to if the user enters an incorrect command
    • ParentCommand

      public ParentCommand(CostManager prices, CooldownManager cooldowns, String command, boolean runAsync)
  • Method Details

    • addSubCommands

      public void addSubCommands(SubCommand... commands)
      Add multiple subcommands (see addSubCommand(SubCommand))
      Parameters:
      commands - The command(s) to add
    • addSubCommand

      public void addSubCommand(SubCommand command)
      this method adds another command to the parent command
      Parameters:
      command - the command to add
    • onCommand

      public CommandResponse onCommand(org.bukkit.command.CommandSender sender, String label, String[] args)
      Description copied from class: SubCommand

      This method is called whenever the sub command is run, return the message (+ chat color if it should not be the default chat color)

      The return value should be the value of the message to be sent to the user, for more complicated messaging systems return null

      Specified by:
      onCommand in class SubCommand
      Parameters:
      sender - the person who called the command
      label - the label of the initial command (useful for help files)
      args - the arguments of the sub command (starting at args[0], as the sub command itself will be removed)
      Returns:
      the message
    • onCommand

      public CommandResponse onCommand(org.bukkit.command.CommandSender sender, String label, String[] args, boolean first)
    • getMinimumArguments

      public int getMinimumArguments()
      Description copied from class: SubCommand
      Used to get the minimum number of arguments which need to be parsed into this command
      Specified by:
      getMinimumArguments in class SubCommand
      Returns:
      the number of minimum arguments
    • getNode

      public String getNode()
      Specified by:
      getNode in class SubCommand
      Returns:
      the permission node for that sub command
    • getHelp

      public String getHelp()
      Specified by:
      getHelp in class SubCommand
      Returns:
      the help information for that sub command (this does not include the arguments)
    • getArguments

      public String getArguments()
      Specified by:
      getArguments in class SubCommand
      Returns:
      the arguments for that sub command ie '[name]'
    • onTabComplete

      public void onTabComplete(List<String> options, org.bukkit.command.CommandSender sender, String label, String[] args)
      Specified by:
      onTabComplete in class SubCommand
    • getMaximumArguments

      public int getMaximumArguments()
      Description copied from class: SubCommand
      return -1 if there is no cap
      Specified by:
      getMaximumArguments in class SubCommand
      Returns:
      the maximum number of arguments for the command
    • getReference

      public String getReference(SubCommand subCommand)
    • runAsync

      protected boolean runAsync(String[] args)
      Overrides:
      runAsync in class SubCommand
    • checkAsync

      public boolean checkAsync(String[] args)
      Overrides:
      checkAsync in class SubCommand
    • getSubCommands

      public HashMap<String,SubCommand> getSubCommands()
      Used to store all applicable sub commands
    • getCommand

      public String getCommand()
      Used to store what the parent command reference is
      Specified by:
      getCommand in class SubCommand
      Returns:
      the sub-command which this class handles