Skip to content
This repository was archived by the owner on Mar 8, 2022. It is now read-only.

CommandReceiver and language file

Recursive G edited this page Dec 2, 2016 · 8 revisions

The CommandReceiver provided an easy way to construct command handler.
Simply extends CommandReceiver<PluginMainClass> and done!

Register

You should and only should register your main command handler this way

commandHandler = new CommandHandler(this, i18n);
getCommand("nyaautils").setExecutor(commandHandler);

Command line arguments

Command line is automatically parsed by CommandReceiver.Arguments class.
Arguments are separated by space, extra spaces are allowed.
Singe argument containing special characters should be embraced by `
Backslash \ is used as the escape character but it is only valid inside the backquote
For example

/examplecommand first  `second` `thir\`d` `fourt\\h` ``

contains five arguments:

  • first
  • second
  • thir`d
  • fourt\h
  • an empty string

Subcommands

A subcommand handler is a field or a method inside a command handler class.
It should be annotated with @SubCommand annotation.
If it's a field, this field type should have a constructor in this form

public <init>(Object plugin, Internationalization i18n);
Clone this wiki locally