Command Library

Source | Discord | FlashLabs

  • Version: v0.1.1
  • Dependencies: None

The command library provides a service for creating and registering commands in hierarchies, as well as other common actions for commands.

QuickStart

  • Note: Complete documentation is being worked on, and it will take us some time to write everything out. If you have any questions, feel free to ask in the #flashlibs channel on Discord

The command library has two classes: Command, which represents an executable command, and CommandService, which manages initialization and registration.

To create a command, we make a subclass of Command and then set information such as aliases, permission, and children through the provided Builder

public class CustomCommand extends Command {

    @Inject
    private CustomCommand(Builder builder) {
        super(builder
                .aliases("alias-one", "alias-two", "/primary-alias")
                .permission("plugin-id.command.custom.base")
                .children(SubcommandOne.class, SubcommandTwo.class)
        );
    }

}

Finally, we can register our custom command using the CommandService.

PluginContainer container;
CommandService commands = CommandService.of(container);
commands.register(CustomCommand.class);

The Plugin library can automatically provide a CommandService for your plugin.

The remaining documentation hasn’t been written yet, but it should be feasible to piece together things using the javadocs. If you have any questions feel free to ask on Discord. If you’d like to help write documentation we would greatly appreciate it!

Category: Developer Tools

Published on Apr 6, 2020

views

stars

watchers

total downloads

Licensed under MIT

Promoted Versions

Members