Skip to content
Daniel Ennis edited this page Apr 21, 2017 · 13 revisions

Annotations

This document will describe the available annotations and where and how they can be used

CommandAlias

  • On the Class itself to define the base commands for all sub commands defined, Separate with | to define multiple
  • On Subcommands to define aliases for the subcommand as root commands. Example if your command is /foo bar - then adding a @CommandAlias("fb") makes /fb the same as /foo bar

CommandCompletion

  • Defined on Subcommands. Defines the possible command completions for each argument.
    If you have 3 arguments to your command, and you supply Foo|foo1 bar|bar2 baz|baz3 Then when you press tab on the first arg, you will receive Foo and foo1 as completion options, on arg 2 you will receive bar and bar2, etc...

CommandPermission

  • Require a Permission node to execute this command @CommandPermission("foo.bar")

Optional

  • Can only be used (currently) at end of the command for non Player arguments. Makes it so that if nothing is entered to resolve this context, it will simply return null
  • Any arg of type Player will verify its a Player executing it, and give the console an error. If the player can be optional, you may use @Optional on it and it will be null.

Default

  • Similar to @Optional, but instead of returning null, it fills in a default value, and passes that value to the context resolver.

Flags

  • Used to change the behavior of Context Resolvers. For example, putting @Flags("itemheld") on a player will return an error if the Player is not holding an item. A way to define common restrictions

Single

  • By default, a String argument at the end of command signature is expected to consume "everything remaining", if you want it to ignore extra text and only consume a single word input, use this.

Split

  • Applied on String[], defines a character to split on So if the user types foo,bar and you have @Split(",") you will get an array of strings with foo and bar.

Subcommand

  • Defines a subcommand on a Command class
  • May use spaces to separate depth, for example @Subcommand("foo bar baz") would require the command start with foo bar baz to match to this sub command, and then everything after baz is passed to the arguments for resolve.
  • You may pipe delimit every part to provide alter versions, and every possible permutation will be available. For example foo|f bar|b will provide:
    • foo bar
    • foo b
    • f bar
    • f b

Syntax

  • ACF will automatically generate syntax formats for you on incorrect usage of commands. This lets you override that. @Syntax("<foo> - Something something")

Values

  • Restricts input to a static list of Values, and errors if does not match
  • Can be dynamic by using Command Completion codes
  • If this is set on the last parameter that happens to be a string, the @Single rule is enforced, and it will not consume the rest of the input.