Skip to content
Permalink
Browse files

Allow removing of -g group flags with /region flag

The @command parser requires that a value follow the -g option when
used in /refion flag. Therefore, it's not possible to remove the -g
flag by omitting it's value, as it is possible with the regular flags.

Rather, if the group flag is set to what would be the default region
group for the normal flag, then the group flag is actually removed
and the user sees a "Region group flagfor '...' reset to default."
message.
  • Loading branch information...
thvortex authored and sk89q committed Oct 24, 2012
1 parent 68b5e3e commit 2cbc2f5226829be81405d1138d345069d6f87a2e
Showing with 13 additions and 4 deletions.
  1. +13 −4 src/main/java/com/sk89q/worldguard/bukkit/commands/RegionCommands.java
@@ -765,19 +765,28 @@ public void flag(CommandContext args, CommandSender sender) throws CommandExcept

if (args.hasFlag('g')) {
String group = args.getFlag('g');
if (foundFlag.getRegionGroupFlag() == null) {
RegionGroupFlag groupFlag = foundFlag.getRegionGroupFlag();
if (groupFlag == null) {
throw new CommandException("Region flag '" + foundFlag.getName()
+ "' does not have a group flag!");
}

try {
setFlag(region, foundFlag.getRegionGroupFlag(), sender, group);
// If group set to default value then clear the group flag
RegionGroup groupValue = groupFlag.parseInput(plugin, sender, group);
if (groupValue == groupFlag.getDefault()) {
region.setFlag(groupFlag, null);
sender.sendMessage(ChatColor.YELLOW
+ "Region group flag for '" + foundFlag.getName() + "' reset to default.");
} else {
region.setFlag(groupFlag, groupValue);
sender.sendMessage(ChatColor.YELLOW
+ "Region group flag for '" + foundFlag.getName() + "' set.");
}
} catch (InvalidFlagFormat e) {
throw new CommandException(e.getMessage());
}

sender.sendMessage(ChatColor.YELLOW
+ "Region group flag for '" + foundFlag.getName() + "' set.");
} else {
if (value != null) {
try {

0 comments on commit 2cbc2f5

Please sign in to comment.
You can’t perform that action at this time.