-
Notifications
You must be signed in to change notification settings - Fork 0
Flags
mario edited this page Mar 29, 2026
·
1 revision
Flags are optional boolean parameters that can be passed in any order, independently
of positional arguments. They are declared with @Flag and always default to false.
| Property | Type | Default | Description |
|---|---|---|---|
value |
String |
— | Short flag name, e.g. -s. |
aliases |
String[] |
{} |
Long-form aliases, e.g. --silent. |
description |
String |
"" |
Human-readable description shown in usage messages. |
defaultValue |
boolean |
true |
Value returned when the flag is present. |
@Command(names = {"ban"}, permission = "plugin.ban")
public void banCommand(CommandSender sender,
@Param(name = "player") Player target,
@Param(name = "reason", concated = true) String reason,
@Flag(value = "-s", aliases = "--silent", description = "Ban without broadcasting") boolean silent) {
target.kickPlayer(reason);
if (!silent) {
Bukkit.broadcastMessage(target.getName() + " was banned: " + reason);
}
}Both of these are valid:
/ban Steve Cheating
/ban Steve Cheating -s
/ban Steve Cheating --silent
- Flags can appear anywhere in the argument list — before, after, or between positional arguments.
- A command can have multiple flags.
- Flags are always optional and never affect the usage message's positional argument count.