Added -a flag to region remove owner/member commands to remove all.

This commit is contained in:
Albert Pham 2013-05-29 13:22:47 -07:00
parent ae158742f6
commit b7d38e94c8
2 changed files with 27 additions and 8 deletions

View File

@ -174,9 +174,9 @@ public void addOwner(CommandContext args, CommandSender sender) throws CommandEx
@Command(aliases = {"removemember", "remmember", "removemem", "remmem"},
usage = "<id> <owners...>",
flags = "w:",
flags = "aw:",
desc = "Remove an owner to a region",
min = 2)
min = 1)
public void removeMember(CommandContext args, CommandSender sender) throws CommandException {
final World world;
Player player = null;
@ -216,7 +216,14 @@ public void removeMember(CommandContext args, CommandSender sender) throws Comma
}
}
RegionDBUtil.removeFromDomain(region.getMembers(), args.getPaddedSlice(2, 0), 0);
if (args.hasFlag('a')) {
region.getMembers().removaAll();
} else {
if (args.argsLength() < 2) {
throw new CommandException("List some names to remove, or use -a to remove all.");
}
RegionDBUtil.removeFromDomain(region.getMembers(), args.getPaddedSlice(2, 0), 0);
}
sender.sendMessage(ChatColor.YELLOW
+ "Region '" + id + "' updated.");
@ -231,9 +238,9 @@ public void removeMember(CommandContext args, CommandSender sender) throws Comma
@Command(aliases = {"removeowner", "remowner"},
usage = "<id> <owners...>",
flags = "w:",
flags = "aw:",
desc = "Remove an owner to a region",
min = 2)
min = 1)
public void removeOwner(CommandContext args,
CommandSender sender) throws CommandException {
final World world;
@ -274,7 +281,14 @@ public void removeOwner(CommandContext args,
}
}
RegionDBUtil.removeFromDomain(region.getOwners(), args.getPaddedSlice(2, 0), 0);
if (args.hasFlag('a')) {
region.getOwners().removaAll();
} else {
if (args.argsLength() < 2) {
throw new CommandException("List some names to remove, or use -a to remove all.");
}
RegionDBUtil.removeFromDomain(region.getOwners(), args.getPaddedSlice(2, 0), 0);
}
sender.sendMessage(ChatColor.YELLOW
+ "Region '" + id + "' updated.");

View File

@ -30,8 +30,8 @@
import com.sk89q.worldguard.LocalPlayer;
public class DefaultDomain implements Domain {
private Set<String> groups;
private Set<String> players;
private final Set<String> groups;
private final Set<String> players;
public DefaultDomain() {
this.groups = new LinkedHashSet<String>();
@ -135,4 +135,9 @@ public String toUserFriendlyString() {
return str.toString();
}
public void removaAll() {
groups.clear();
players.clear();
}
}