Create a new Java class for your command. Command methods can be static or instance methods.
package com.example.commands;import me.vaperion.blade.annotation.command.Command;import me.vaperion.blade.annotation.command.Description;import me.vaperion.blade.annotation.command.Permission;import me.vaperion.blade.annotation.parameter.Name;import me.vaperion.blade.annotation.parameter.Sender;import org.bukkit.entity.Player;public class GreetCommand { @Command("greet") @Description("Send a greeting to a player") @Permission("example.greet") public void greet( @Sender Player sender, @Name("player") Player target ) { sender.sendMessage("Hello " + target.getName() + "!"); target.sendMessage(sender.getName() + " says hello!"); }}
1
Annotate the method
Use @Command to define the command name. The annotation value becomes the command that players type in chat.
2
Add a description
Use @Description to provide a description for your command. This appears in help messages.
3
Set permissions
Use @Permission to restrict who can use the command. Players need this permission to execute the command.
4
Define parameters
@Sender marks the command executor (required first parameter)
@Name specifies the argument name shown in usage messages
The @Sender parameter is required and must be the first parameter. It represents the entity executing the command (Player, ConsoleCommandSender, etc.).
You can define multiple command methods in a single class:
public class SocialCommands { @Command("greet") public void greet(@Sender Player sender, @Name("player") Player target) { // Greeting logic } @Command("wave") public void wave(@Sender Player sender, @Name("player") Player target) { // Waving logic } @Command("hug") public void hug(@Sender Player sender, @Name("player") Player target) { // Hugging logic }}
Create subcommands by using spaces in the command annotation:
public class AdminCommands { @Command("admin reload") @Permission("example.admin.reload") public void reload(@Sender Player sender) { // Reload logic } @Command("admin debug") @Permission("example.admin.debug") public void debug(@Sender Player sender) { // Debug logic }}
You can customize error messages in your configuration:
Blade.forPlatform(new BladeBukkitPlatform(this)) .config(cfg -> { cfg.defaultPermissionMessage("§cYou don't have permission to use this command!"); }) .build();