}
Set<AutoRefTeam> teams = Sets.newHashSet();
for (String arg : args)
{
AutoRefTeam team = match.getTeam(arg);
if (team != null) teams.add(team);
}
boolean isStartRegion = options.hasOption('S');
if (teams.isEmpty() && !isStartRegion)
{
// team name is invalid. let the player know
sender.sendMessage(ChatColor.DARK_GRAY + "No valid team names given.");
sender.sendMessage("Teams are " + match.getTeamList());
return true;
}
Selection sel = worldEdit.getSelection(player);
AutoRefRegion reg = null;
if ((sel instanceof CuboidSelection))
{
CuboidSelection csel = (CuboidSelection) sel;
reg = new CuboidRegion(csel.getMinimumPoint(), csel.getMaximumPoint());
}
// if we couldn't get a region from WorldEdit
if (reg == null) return false;
// add the selection to the start regions
if (isStartRegion)
{
match.addStartRegion(reg);
sender.sendMessage("Region now marked as a start region!");
return true;
}
// name this region if it has a name
if (options.hasOption('N'))
reg.setName(options.getOptionValue('N', null));
for (AutoRefRegion.Flag flag : AutoRefRegion.Flag.values())
if (options.hasOption(flag.getMark())) reg.toggle(flag);
for (AutoRefTeam team : teams) if (team.addRegion(reg))
sender.sendMessage(reg.toString() + " set as " + team.getDisplayName() + "'s region.");
return true;
}