Util Annotation Command System

Discussion in 'Resources' started by Stumblinbear, Feb 11, 2016.

Thread Status:
Not open for further replies.
  1. Offline


    Look, I know this has been done before. But this is my interpretation. It's all compacted into a single class for ease of use.

    • Argument handling
    • Argument type enforcement
    • Argument parse classes
    • Allows quotes to combine args (e.g. /<command> "argument text")
    • Tab completions
    • Command prediction
    • (sub-)*commands
    • Error handling
    • Help pages
    • Specific command help pages
    • Permission checks
    It's documented too :u

    Command prediction:

    If a used command does not exist, an attempt to find the most fitting command is done. For example, I have a command called "test". I create a sub command using @CMD called "one". If a player runs /test oen, the plugin will ask if they meant "/test one?" The command in chat is clickable, and runs the SUGGEST_COMMAND event to insert it into their chat input.

    No need to include the command in your plugin.yml!

    Gist: https://gist.github.com/Stumblinbear/c27f1fe584c130690b8f

    // Firstly, just register the command manager.
    // This creates a new command labeled /test with the alias /tst
    CommandManager cm = new CommandManager(this, "Test Tag", "test.node", "test", "tst");
    // new CommandManager(plugin, help menu tag, permission node scheme, the command, alias1, alias2..., alias37);
    // Then load a commands class. You can add as many as you want~
    Inside your TestCommands class file, register new commands like so:
    // @Cmd can include as many arguments as you want
    @Cmd(cmd = "one", // Run this command using /<command> one
           args = "[bool]", // Optional argument.
           argTypes = { Arg.ArgBoolean.class }, // Enforce the first argument as a boolean.
           help = "Test Command #1", // Command help
           longhelp = "More detailed info on Test Command #1", // More detailed help! Shown with /<command> help one
           only = CommandOnly.OP, // Only all OP. Permission can override this.
           permission = "one") // Permission node is test.node.one
       public static CommandFinished cmdTestOne(CommandSender sender, Object[] args) {
         return CommandFinished.DONE;
    // ... or as few.
    @Cmd(cmd = "two")
    // subcommands
    // You must enclose required args in <>'s. Optional can be in any format, though []'s are preferred.
    @Cmd(cmd = "two three", args = "<text> [meow]")
    @Cmd(cmd = "two four", args = "[text]")
    Pretty simple, eh? :v?
Thread Status:
Not open for further replies.

Share This Page