// basic 'plot fs' command
setPlotForSale(resident, pos, plotPrice);
}
} else if (split[0].equalsIgnoreCase("perm")) {
TownBlock townBlock = new WorldCoord(world, Coord.parseCoord(player)).getTownBlock();
TownyMessaging.sendMessage(player, TownyFormatter.getStatus(townBlock));
} else if (split[0].equalsIgnoreCase("toggle")) {
TownBlock townBlock = new WorldCoord(world, Coord.parseCoord(player)).getTownBlock();
// Runs tests to make sure we are allowed to work on this plot.
// Ignore the returns as we are only checking for an exception
plotTestOwner(resident, townBlock);
townBlock.getTown();
plotToggle(player, new WorldCoord(world, Coord.parseCoord(player)).getTownBlock(), StringMgmt.remFirstArg(split));
} else if (split[0].equalsIgnoreCase("set")) {
split = StringMgmt.remFirstArg(split);
Town town = resident.getTown();
if (split.length > 0) {
if (split[0].equalsIgnoreCase("perm")) {
//Set plot level permissions (if the plot owner) or Mayor/Assistant of the town.
TownBlock townBlock = new WorldCoord(world, Coord.parseCoord(player)).getTownBlock();
// Test we are allowed to work on this plot
TownBlockOwner owner = plotTestOwner(resident, townBlock);
town = townBlock.getTown();
// Check we are allowed to set these perms
toggleTest(player, townBlock, StringMgmt.join(StringMgmt.remFirstArg(split), ""));
TownCommand.setTownBlockPermissions(player, owner, townBlock.getPermissions(), StringMgmt.remFirstArg(split), true);
townBlock.setChanged(true);
TownyUniverse.getDataSource().saveTownBlock(townBlock);
return;
}
if ((!TownyUniverse.getPermissionSource().isTownyAdmin(player)) && ((plugin.isPermissions())
&& (!TownyUniverse.getPermissionSource().hasPermission(player, PermissionNodes.TOWNY_TOWN_PLOTTYPE.getNode())))
&& !town.isMayor(resident)
&& !town.hasAssistant(resident))
throw new TownyException(String.format(TownySettings.getLangString("msg_cache_block_error_town_resident"), "change plot types"));
WorldCoord worldCoord = new WorldCoord(world, Coord.parseCoord(player));
TownBlock townBlock = worldCoord.getTownBlock();
setPlotType(resident, worldCoord, split[0]);
townBlock.setChanged(true);
TownyUniverse.getDataSource().saveTownBlock(townBlock);
player.sendMessage(String.format(TownySettings.getLangString("msg_plot_set_type"), split[0]));
} else {
player.sendMessage(ChatTools.formatCommand("", "/plot set", "reset", ""));
player.sendMessage(ChatTools.formatCommand("", "/plot set", "shop|embassy|arena|wilds|spleef", ""));
player.sendMessage(ChatTools.formatCommand("", "/plot set perm", "?", ""));
}
} else if (split[0].equalsIgnoreCase("clear")) {
if (!resident.isMayor())
throw new TownyException(TownySettings.getLangString("msg_not_mayor"));
TownBlock townBlock = new WorldCoord(world, Coord.parseCoord(player)).getTownBlock();
if (townBlock != null) {
if (townBlock.isOwner(resident.getTown()) && (!townBlock.hasResident())) {
for (String material : world.getPlotManagementMayorDelete())
if (Material.matchMaterial(material) != null) {
plugin.getTownyUniverse().deleteTownBlockMaterial(townBlock, Material.getMaterial(material).getId());
player.sendMessage(String.format(TownySettings.getLangString("msg_clear_plot_material"), material));
} else
throw new TownyException(String.format(TownySettings.getLangString("msg_err_invalid_property"), material));
} else
throw new TownyException(String.format(TownySettings.getLangString("msg_already_claimed"), townBlock.getResident().getName()));
} else {
// Shouldn't ever reach here as a null townBlock should be caught already in WorldCoord.
player.sendMessage(TownySettings.getLangString("msg_err_empty_area_selection"));
}