Annotation And Sub Command
Please make sure you have read the Quick Start before the continuous reading.
Annotation
Here's the annotation of command
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Commander {
String name(); // command name (compulsory)
String description(); //command description (compulsory)
boolean playerOnly() default false; // command is only player
String permission() default ""; // command permission
String[] alias() default {}; // command alias
}
playerOnly will not auto cast CommandSender into Player type,you still need to cast it manually.
Sub Command Structure
With this framework, create infinity sub commands are extremely easy.
public class TesterRegistry implements ComponentsRegistry {
@Override
public void registerCommand(CommandRegistry commandRegistry) {
commandRegistry.command(TestCommand.class, c -> {
c.command(TestSayCommand.class);
c.command(TestCalculateCommand.class, cc -> {
cc.command(TestCalculateAddCommand.class);
cc.command(TestCalculateMinusCommand.class);
});
c.command(TestConfigCommand.class, cc -> {
cc.command(TestConfigCheckCommand.class);
cc.command(TestConfigEditCommand.class);
cc.command(TestConfigReloadCommand.class);
});
c.command(TestServiceCommand.class, cc -> {
cc.command(TestServiceByeCommand.class);
cc.command(TestServiceHelloCommand.class);
});
c.command(TestSchedulerCommand.class, cc ->{
cc.command(TestSchedulerOneCommand.class);
cc.command(TestSchedulerTwoCommand.class);
});
});
}
@Override
public void registerListeners(ListenerRegistry listenerRegistry) {
}
}
最后更新于