}
}
if (worldZone == null)
{
throw new CommandException("No world found");
}
if (args.isEmpty())
{
throw new CommandException("Missing arguments!");
}
if (tabCompleteMode)
{
if (!redefine)
return;
for (Zone z: APIRegistry.perms.getZones()) {
if (z instanceof AreaZone) {
if (z.getName().startsWith(args.peek()))
tabComplete.add(z.getName());
if (Integer.toString(z.getId()).startsWith(args.peek()))
tabComplete.add(Integer.toString(z.getId()));
}
}
return;
}
String zoneName = args.remove();
AreaZone zone = getAreaZone(worldZone, zoneName);
if (!redefine && zone != null)
{
throw new CommandException(String.format("Area \"%s\" already exists!", zoneName));
}
else if (redefine && zone == null)
{
throw new CommandException(String.format("Area \"%s\" does not exist!", zoneName));
}
if (args.isEmpty())
{
if (!(sender instanceof EntityPlayerMP))
{
throw new CommandException("Command not usable from console. Try /zone set <name> <coords> instead");
}
PlayerInfo info = PlayerInfo.getPlayerInfo((EntityPlayerMP) sender);
AreaBase area = info.getSelection();
if (area == null)
throw new CommandException("No selection available. Please select a region first.");
PermissionContext context = new PermissionContext();
context.setCommandSender(sender);
context.setTargetLocationStart(area.getLowPoint().toVec3());
context.setTargetLocationEnd(area.getHighPoint().toVec3());
if (!PermissionsManager.checkPermission(context, PERM_DEFINE))
{
throw new CommandException("You don't have the permission to define an area.");
}
if (redefine)
{
zone.setArea(area);
OutputHandler.chatConfirmation(sender, String.format("Area \"%s\" has been redefined.", zoneName));
}
else
{
zone = new AreaZone(worldZone, zoneName, area);
OutputHandler.chatConfirmation(sender, String.format("Area \"%s\" has been defined.", zoneName));
}
}
else if (args.size() >= 3)
{
throw new CommandException("Not yet implemented!");
}
}