This repository has been archived by the owner on Jun 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Creating a basic command
Alan Gomes edited this page May 21, 2019
·
1 revision
All commands are based in the Picocli's API, the only difference is that the classes are
automatically registered at the start of the plugin.
To allow auto registration, you also need to annotate all classes with @Component
.
Example of a command:
@Component
@CommandLine.Command(name = "hello")
public class HelloCommand implements Callable<String> {
@CommandLine.Parameters(index = "0", defaultValue = "world")
private String name;
@Override
public String call() {
return "hello " + name;
}
}
If you need the sender of the command, you can also retrieve it in the Context
:
@Component
@CommandLine.Command(name = "heal")
public class HealCommand implements Runnable {
@Autowired
private Context context;
@Override
public void run() {
Player player = context.getPlayer();
player.setHealth(20);
}
}
In addition, you can also inject the Plugin
and Server
instances via @Autowired
- Getting started
- Commands
- Utilities
- Context
- RxJava support
- Known issues
- Testing