Commands Module
Thanks to this module you can create parent commands and every sub-command in separate classes.
You can add a tab completer to the parent command, but it won't be required.
Module must be shaded to your JAR file
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.timsixth.MinigameAPI</groupId>
<artifactId>commands</artifactId>
<version>{VERSION}</version>
</dependency>
How to register Commands Module?
//Add new instance of Commands Module to registerModules method in configure method
@Override
protected LibraryConfiguration configure() {
commandsModule = new CommandsModule(this);
//or use your own command configurator
commandsModule = new CommandsModule(this, new MyCommandConfigurator());
return new LibraryConfiguration(this, getConfiguratorsInitializer())
.builder()
.setGameManager(new MyGameManager(this, settings, messages))
.registerModules(commandsModule) //new way how to register command module
.build();
}
How to define command configurator?
public class MyCommandConfigurator extends DefaultCommandConfigurator {
@Override
public CommandConfiguration configure() {
return CommandConfiguration.builder()
.doNotHavePermissionMessage("No permission")
.onlyPlayersMessage("Only players can use this command")
.build();
}
}
Last updated