Deleting a region flag also deletes group flag

The group flags set with /region flag -g have no effect if the
normal flag is not also set, nor will they be displayed with
/region info once the normal flag is deleted. However, if a
group flag was to remain set in the database, the next time a
user sets the normal flag, they might be surprised to suddenly
see the corresponding group set as well.

Since the -g group is presented to the user as an attribute of
the normal flag, rather than a standalone flag, the group flag
should be deleted along with the normal flag.
This commit is contained in:
Wojciech Stryjewski 2012-10-24 17:09:34 -05:00 committed by sk89q
parent 7e419c116e
commit bb9dff7b8c

View File

@ -798,6 +798,12 @@ public void flag(CommandContext args, CommandSender sender) throws CommandExcept
// Clear the flag only if neither [value] nor [-g group] was given
region.setFlag(foundFlag, null);
// Also clear the associated group flag if one exists
RegionGroupFlag groupFlag = foundFlag.getRegionGroupFlag();
if (groupFlag != null) {
region.setFlag(groupFlag, null);
}
sender.sendMessage(ChatColor.YELLOW
+ "Region flag '" + foundFlag.getName() + "' cleared.");
}