-
-
Notifications
You must be signed in to change notification settings - Fork 150
Using ACF
See Maven, Gradle, or you can find artifacts here:
https://repo.aikar.co/content/groups/aikar/co/aikar/commands/
BukkitCommandManager manager = new BukkitCommandManager(yourBukkitPlugin);
First you need to create a class that extends BaseCommand
, then register that command with the manager
manager.registerCommand(new MyCommand());
If you need your plugin instance, pass it to your commands constructor like so
manager.registerCommand(new MyCommand(myPlugin));
Special Completion Handlers are prefixed @ like @foo
To register your own custom ones, one would do
manager.getCommandCompletions().registerCompletion("foo", c -> {
return ImmutableList.of("some", "custom", "completion");
});
Command Context Handlers are able to resolve input to custom Java objects.
To register your own custom ones, one would do
manager.getCommandContexts().registerContext(Foo.class, c -> {
return /* stuff */;
});
See CommandExecutionContext for information on what methods are available for (c) See CommandContexts and BukkitCommandContexts for examples.
You may also use registerIssuerAwareContext
instead to tell ACF that this resolver is able to resolve without consuming input, by understanding the context of the issuer of the command (such as World, Location, Etc)
A non issuer aware resolver must consume input. Issuer Aware may optionally consume input if supplied, and fallback to context if not.
If you want an Issuer Only resolver, one that always resolves based on Issuer and never consumes input, you may use registerIssuerOnlyContext