@Command( name = "unclaim", permission = "mytown.cmd.assistant.unclaim", parentName = "mytown.cmd", syntax = "/town unclaim") public static CommandResponse unclaimCommand(ICommandSender sender, List<String> args) { EntityPlayer player = (EntityPlayer) sender; Resident res = MyTownUniverse.instance.getOrMakeResident(sender); TownBlock block = getBlockAtResident(res); Town town = getTownFromResident(res); if (town != block.getTown()) throw new MyTownCommandException("mytown.cmd.err.unclaim.notInTown"); if (block.isPointIn(town.getSpawn().getDim(), town.getSpawn().getX(), town.getSpawn().getZ())) throw new MyTownCommandException("mytown.cmd.err.unclaim.spawnPoint"); if (!checkNearby(block.getDim(), block.getX(), block.getZ(), town) && town.townBlocksContainer.size() <= 1) { throw new MyTownCommandException("mytown.cmd.err.unclaim.lastClaim"); } getDatasource().deleteBlock(block); res.sendMessage( getLocal() .getLocalization( "mytown.notification.block.removed", block.getX() << 4, block.getZ() << 4, block.getX() << 4 + 15, block.getZ() << 4 + 15, town.getName())); makeBankRefund(player, town, block.getPricePaid()); return CommandResponse.DONE; }
public Location getTownSpawnLocation(Player player) throws TownyException { try { Resident resident = getDataSource().getResident(player.getName()); Town town = resident.getTown(); return town.getSpawn(); } catch (TownyException x) { throw new TownyException("Unable to get spawn location"); } }
@Command( name = "setspawn", permission = "mytown.cmd.assistant.setspawn", parentName = "mytown.cmd", syntax = "/town setspawn") public static CommandResponse setSpawnCommand(ICommandSender sender, List<String> args) { EntityPlayer player = (EntityPlayer) sender; Resident res = MyTownUniverse.instance.getOrMakeResident(player); Town town = getTownFromResident(res); if (!town.isPointInTown(player.dimension, (int) player.posX, (int) player.posZ)) throw new MyTownCommandException( getLocal().getLocalization("mytown.cmd.err.setspawn.notintown", town.getName())); makePayment(player, Config.instance.costAmountSetSpawn.get()); town.getSpawn() .setDim(player.dimension) .setPosition((float) player.posX, (float) player.posY, (float) player.posZ) .setRotation(player.cameraYaw, player.cameraPitch); getDatasource().saveTown(town); res.sendMessage(getLocal().getLocalization("mytown.notification.town.setspawn")); return CommandResponse.DONE; }