✨ Add command argument preprocessors
This commit is contained in:
parent
fcd269b6e7
commit
1f3c3f2bd9
9 changed files with 405 additions and 17 deletions
|
|
@ -35,6 +35,7 @@ import cloud.commandframework.annotations.CommandMethod;
|
|||
import cloud.commandframework.annotations.CommandPermission;
|
||||
import cloud.commandframework.annotations.Confirmation;
|
||||
import cloud.commandframework.annotations.Flag;
|
||||
import cloud.commandframework.annotations.Regex;
|
||||
import cloud.commandframework.annotations.specifier.Greedy;
|
||||
import cloud.commandframework.arguments.CommandArgument;
|
||||
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||
|
|
@ -440,4 +441,16 @@ public final class ExamplePlugin extends JavaPlugin {
|
|||
player.sendMessage(ChatColor.GREEN + String.format("You have been given %d x %s", number, material));
|
||||
}
|
||||
|
||||
@CommandMethod("example pay <money>")
|
||||
@CommandDescription("Command to test the preprocessing system")
|
||||
private void commandPay(
|
||||
final @NonNull CommandSender sender,
|
||||
final @Argument("money") @Regex("(?=.*?\\d)^\\$?(([1-9]\\d{0,2}(,\\d{3})*)|\\d+)?(\\.\\d{1,2})?$") String money
|
||||
) {
|
||||
bukkitAudiences.sender(sender).sendMessage(
|
||||
Component.text().append(Component.text("You have been given ", NamedTextColor.AQUA))
|
||||
.append(Component.text(money, NamedTextColor.GOLD))
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue