Esempio 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;
  }
Esempio n. 2
0
  @Command(
      name = "kick",
      permission = "mytown.cmd.assistant.kick",
      parentName = "mytown.cmd",
      syntax = "/town kick <resident>",
      completionKeys = {"residentCompletion"})
  public static CommandResponse kickCommand(ICommandSender sender, List<String> args) {
    if (args.size() < 1) {
      return CommandResponse.SEND_SYNTAX;
    }
    Resident res = MyTownUniverse.instance.getOrMakeResident(sender);
    Resident target = getResidentFromName(args.get(0));
    Town town = getTownFromResident(res);
    if (!target.townsContainer.contains(town)) {
      throw new MyTownCommandException(
          "mytown.cmd.err.resident.notsametown", args.get(0), town.getName());
    }
    if (target == res) {
      throw new MyTownCommandException("mytown.cmd.err.kick.self");
    }

    if (town.residentsMap.get(target) == town.ranksContainer.getMayorRank()) {
      throw new MyTownCommandException("mytown.cmd.err.kick.mayor");
    }

    getDatasource().unlinkResidentFromTown(target, town);
    target.sendMessage(
        getLocal().getLocalization("mytown.notification.town.kicked", town.getName()));
    town.notifyEveryone(
        getLocal()
            .getLocalization(
                "mytown.notification.town.left", target.getPlayerName(), town.getName()));
    return CommandResponse.DONE;
  }