When validation fails, Blade sends an error message to the command sender:
The parameter 'level' must be between 1 and 100
You can customize error messages globally through the Blade builder:
Blade.forPlatform(plugin) .config(config -> config .invalidNumberError("Invalid number for '%s'") .numberOutOfRangeError("'%s' must be between %s and %s") ) .build();
Forwarded annotations are ignored by Blade’s parameter resolver and passed directly to the argument provider. This is cleaner than using @Data for structured metadata.
Blade automatically handles validation errors and sends appropriate messages:
@Command("setlevel")public void setLevel(@Name("level") @Range(min = 1, max = 100) int level) {}// Input: /setlevel 150// Output: The parameter 'level' must be between 1 and 100
For complex validation, use custom argument providers:
public class PositiveIntProvider implements ArgumentProvider<Integer> { @Override public Integer provide(Context context, Argument argument) throws BladeExitMessage { int value = Integer.parseInt(argument.getString()); if (value <= 0) { throw new BladeExitMessage("Value must be positive!"); } return value; }}@Command("example")public void example( @Name("value") @Provider(PositiveIntProvider.class) int value) { // value is guaranteed to be positive}
@Command("transfer")public void transferCommand( @Sender Player player, @Name("target") @Provider(OnlinePlayerProvider.class) Player target, @Name("amount") @Range(min = 1, max = 10000) int amount) { // Both custom provider validation AND range validation if (player.equals(target)) { throw new BladeExitMessage("You cannot transfer to yourself!"); } transferMoney(player, target, amount);}