Skip to content

AnnotationCommand

Hakan Kargın edited this page May 25, 2022 · 4 revisions

How To Use

Annotation Command System

With this feature you don't need plugin.yml anymore.

Just type the command name in the BaseCommand annotation; HCommands will take care of that for you. Also, HCommands provides automatic tab completion for subcommands without any effort.

Example

@BaseCommand(
        name = "example",
        description = "Example command",
        usage = "/example",
        aliases = {"ex"}
)
public class ExampleCommand implements HCommandAdapter {

    @SubCommand(
            permission = "example.main"
    )
    public void mainCommand(CommandSender sender, String[] args) {
        sender.sendMessage("main command");
    }

    @SubCommand(
            args = {"admin", "set"},
            permission = "example.admin.set"
    )
    public void testCommand(CommandSender sender, String[] args) {
        sender.sendMessage("you used - /example " + String.join(" ", args));
    }

    @SubCommand(
            args = {"admin", "test"},
            permission = "example.admin.deneme"
    )
    public void testCommand2(CommandSender sender, String[] args) {
        sender.sendMessage("you used - /example " + String.join(" ", args));
    }

    @SubCommand(
            args = {"player", "pay"},
            permission = "example.admin.deneme"
    )
    public void testCommand3(CommandSender sender, String[] args) {
        sender.sendMessage("you used - /example " + String.join(" ", args));
    }
}
HCore.registerCommands(new ExampleCommand());

That's all

Clone this wiki locally