-
Notifications
You must be signed in to change notification settings - Fork 0
Your first command
mario edited this page Mar 29, 2026
·
1 revision
Before registering commands, tell the framework which plugin instance it's working with.
The easiest way is to scan an entire package — the framework will find and register
every @Command method automatically.
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
BukkitCommandHandler.registerCommands("me.myplugin.commands", this);
}
}Create a class in that package and annotate a method with @Command.
public class MyCommands {
@Command(names = {"hello"}, playerOnly = true)
public void helloCommand(Player sender) {
sender.sendMessage(ChatColor.GREEN + "Hello, " + sender.getName() + "!");
}
}@Command(names = {"greet"}, playerOnly = true)
public void greetCommand(Player sender, @Param(name = "target") Player target) {
sender.sendMessage(ChatColor.GREEN + "Hello, " + target.getName() + "!");
}That's it. Tab completion, usage messages, and player resolution are all handled automatically.
- Add permissions, flags, and optional arguments → Bukkit
- Group related subcommands → Subcommand Groups
- Parse custom types → Custom Processors