Annotation Interface Subcommand


@Target(METHOD) @Retention(RUNTIME) public @interface Subcommand
This annotation should be used to mark methods as subcommand methods. Subcommand methods can have custom arguments (current supported arguments can be found in the ContextProvider), and can also have a custom permission. These subcommands can also be annotated with Completions to provide tab completions for the subcommand. The subcommand method must be public, and must be in a class that is registered with the CommandHandler.

Tab completions with the Completions annotation are only supported for subcommands. When registering completions, you only need to define the completion arguments a single time. If there are other methods which function as optional additional arguments for the subcommand, the previously registered arguments will still be present when the user does their tab completion.

For example, if you have a subcommand method with the arguments (Player, String), and another method which has the arguments (Player, String, String), the tab completions for the second method will still have the Player and String arguments registered from the first method. You will only need to provide a Completion for the additional 3rd argument.

Additionally, if the final argument is a String object, the BukkitDelegate will automatically append any additional arguments to the end of the String. For example, if you have a subcommand method with the arguments (Player, String), and the user executes the command with the arguments /command playerName arg2 arg3, the String argument will be "arg2 arg3". This allows for us to use a String at the end of our subcommand arguments to allow for the user to input a reason.

  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
     
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Class<?>[]
     
  • Element Details

    • permission

      String permission
      Returns:
      The permission to use when executing this subcommand.
    • args

      Class<?>[] args
      Returns:
      The arguments, as classes, to use when registering this subcommand.
      Default:
      {}