Exemplo n.º 1
0
  @Command(
      name = "delete",
      permission = "mytown.cmd.mayor.leave.delete",
      parentName = "mytown.cmd.everyone.leave",
      syntax = "/town leave delete")
  public static CommandResponse leaveDeleteCommand(ICommandSender sender, List<String> args) {
    Resident res = MyTownUniverse.instance.getOrMakeResident(sender);
    Town town = getTownFromResident(res);
    EntityPlayer player = (EntityPlayer) sender;

    if (town.residentsMap.get(res).getType() == Rank.Type.MAYOR) {
      town.notifyEveryone(
          getLocal()
              .getLocalization(
                  "mytown.notification.town.deleted", town.getName(), res.getPlayerName()));
      int refund = 0;
      for (TownBlock block : town.townBlocksContainer) {
        refund += block.getPricePaid();
      }
      refund += town.bank.getAmount();
      makeRefund(player, refund);
      getDatasource().deleteTown(town);
    }
    return CommandResponse.DONE;
  }
Exemplo n.º 2
0
  @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;
  }