Class CommandManager

java.lang.Object
org.reprogle.honeypot.common.commands.CommandManager
All Implemented Interfaces:
org.bukkit.command.CommandExecutor, org.bukkit.command.TabCompleter, org.bukkit.command.TabExecutor

public class CommandManager extends Object implements org.bukkit.command.TabExecutor
  • Constructor Details

    • CommandManager

      public CommandManager()
      Registers all commands
  • Method Details

    • onCommand

      public boolean onCommand(@NotNull org.bukkit.command.CommandSender sender, @NotNull org.bukkit.command.Command command, @NotNull String label, @NotNull String[] args)
      Called by Bukkit when a player runs a command registered to our plugin. When called, the plugin will check if the sender is a player. If it is, it will first verify permissions, then verify if there were any subcommands. If not, show the GUI. If there were subcommands, but they aren't valid, show the usage.

      If the sender is not a player, it will check if the command was reload. If it was, it'll allow the command to be run, otherwise it will throw an error.

      Specified by:
      onCommand in interface org.bukkit.command.CommandExecutor
      Parameters:
      sender - The Sender sending the command. Not necessarily a player, could be console or a plugin
      command - The Command being executed
      label - The label of the command
      args - Any arguments passed to the command
      Returns:
      True if it ran successfully, false if it errored at any point. Defaults as false
    • getSubcommands

      public List<HoneypotSubCommand> getSubcommands()
      Returns a list of all subcommands for tab completion
      Returns:
      List of all subcommands
    • onTabComplete

      @Nullable public List<String> onTabComplete(@NotNull org.bukkit.command.CommandSender sender, @NotNull org.bukkit.command.Command command, @NotNull String alias, @NotNull String[] args)
      This function is responsible for tab completion of our pluign. It will check if the tab completer is at the first arg. If it is, return partial matches for the tab completer. If it's longer than one arg, return partial matches for the subcommand (such as create)
      Specified by:
      onTabComplete in interface org.bukkit.command.TabCompleter
      Parameters:
      sender - The sender of the command
      command - The command being tab completed
      alias - The alias of the command
      args - The arguments passed to the tab completer (Required for tab completion)
      Returns:
      A list of valid tab completed commands