Interface CommandHandler

All Known Subinterfaces:
All Known Implementing Classes:
CollectionCommandHandler, CommandHandler.Silent, HelpCommandHandler

public interface CommandHandler
A CommandHandler handles the execution of a command
  • Method Details

    • getPlugin

      Plugin getPlugin()
      Returns the plugin that created this handler
      The plugin of this handler
    • onRegister

      void onRegister(SubCommand cmd)
      Gets called whenever the command is getting added as handler
      cmd - The command to which the handler has been added to
    • getOverridingUsage

      @Nullable default @Nullable String getOverridingUsage(CommandSenderWrapper senderWrapper)
      Override the shown usage at certain conditions.

      By overriding this method, you may replace SubCommand.getUsage() with something different. E.g. some parameters may require some permissions.

      senderWrapper - The sender of the command
      The overriding usage. null if there is no overriding usage
    • onFire

      void onFire(CommandSender sender, String fullUsage, String[] args)
      Gets called whenever someone executes the command
      sender - The person who executed the command
      fullUsage - The full usage, including the label and everything
      args - Passed arguments to this command
    • onAutocomplete

      @Nullable @Nullable List<String> onAutocomplete(CommandSender sender, String[] args)
      Gets called whenever someone autocompletes (presses tab) on the command
      sender - The person who did the autocomplete
      args - The given arguments
      What shall be shown to the player as options. Returning null will display all players
    • getContentAmount

      @Nullable default @Nullable Integer getContentAmount(CommandSender sender)
      A command may display an amount as an additional info in /bw [...] help

      It's optional. It's not required to override it. Keep in mind that SubCommand.setHasContentAmount(boolean) must be set to true for it to be actually shown

      sender - The sender to which this amount shall be shown
      The amount of entries this (list) command has. null if it shouldn't be shown in this event
    • getBukkitLabel

      default String getBukkitLabel(String fullUsage)
      Returns the name of the command using the given full usage.

      Example: With "/bw arena" this method returns "bw"

      fullUsage - The full usage that's being passed in onFire(CommandSender, String, String[])
      The name of the command that was used to execute the command