}
}
private void parseDefine(ICommandSender sender, WorldZone worldZone, Queue<String> args, boolean redefine)
{
if (!PermissionsManager.checkPermission(new PermissionContext().setCommandSender(sender), PERM_DEFINE))
{
if (!redefine || !PermissionsManager.checkPermission(new PermissionContext().setCommandSender(sender), PERM_REDEFINE))
{
OutputHandler.chatError(sender, FEPermissions.MSG_NO_COMMAND_PERM);
return;
}
}
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.");
}