Ejemplo n.º 1
0
 public void eliminate(Town town) {
   remove(town);
   try {
     checkNation(town.getNation());
   } catch (NotRegisteredException e) {
     TownyMessaging.sendErrorMsg("[War] Error checking " + town.getName() + "'s nation.");
   }
   TownyMessaging.sendGlobalMessage(TownySettings.getWarTimeEliminatedMsg(town.getName()));
   checkEnd();
 }
Ejemplo n.º 2
0
  private void giveBonus(String[] split) throws TownyException {

    Town town;

    try {
      if (split.length != 2)
        throw new TownyException(
            String.format(
                TownySettings.getLangString("msg_err_invalid_input"),
                "Eg: givebonus [town/player] [n]"));
      try {
        town = TownyUniverse.getDataSource().getTown(split[0]);
      } catch (NotRegisteredException e) {
        town = TownyUniverse.getDataSource().getResident(split[0]).getTown();
      }
      try {
        town.setBonusBlocks(town.getBonusBlocks() + Integer.parseInt(split[1].trim()));
        TownyMessaging.sendMsg(
            getSender(),
            String.format(
                TownySettings.getLangString("msg_give_total"),
                town.getName(),
                split[1],
                town.getBonusBlocks()));
      } catch (NumberFormatException nfe) {
        throw new TownyException(TownySettings.getLangString("msg_error_must_be_int"));
      }
      TownyUniverse.getDataSource().saveTown(town);
    } catch (TownyException e) {
      throw new TownyException(e.getMessage());
    }
  }
Ejemplo n.º 3
0
 public boolean loadTowns() {
   sendDebugMsg("Loading Towns");
   for (Town town : universe.getTowns())
     if (!loadTown(town)) {
       System.out.println(
           "[Towny] Loading Error: Could not read town data " + town.getName() + "'.");
       return false;
     }
   return true;
 }
Ejemplo n.º 4
0
 public void remove(WorldCoord worldCoord) {
   try {
     Town town = worldCoord.getTownBlock().getTown();
     TownyMessaging.sendGlobalMessage(
         TownySettings.getWarTimeLoseTownBlockMsg(worldCoord, town.getName()));
     warZone.remove(worldCoord);
   } catch (NotRegisteredException e) {
     TownyMessaging.sendGlobalMessage(TownySettings.getWarTimeLoseTownBlockMsg(worldCoord));
     warZone.remove(worldCoord);
   }
 }
Ejemplo n.º 5
0
  public void parseAdminTownCommand(String[] split) throws TownyException {

    // TODO Make this use the actual town command procedually.

    if (split.length == 0 || split[0].equalsIgnoreCase("?")) {
      sender.sendMessage(ChatTools.formatTitle("/townyadmin town"));
      sender.sendMessage(
          ChatTools.formatCommand(
              TownySettings.getLangString("admin_sing"), "/townyadmin town", "[town]", ""));
      sender.sendMessage(
          ChatTools.formatCommand(
              TownySettings.getLangString("admin_sing"),
              "/townyadmin town",
              "[town] add/kick [] .. []",
              ""));
      sender.sendMessage(
          ChatTools.formatCommand(
              TownySettings.getLangString("admin_sing"),
              "/townyadmin town",
              "[town] rename [newname]",
              ""));
      sender.sendMessage(
          ChatTools.formatCommand(
              TownySettings.getLangString("admin_sing"), "/townyadmin town", "[town] delete", ""));
      sender.sendMessage(
          ChatTools.formatCommand(
              TownySettings.getLangString("admin_sing"), "/townyadmin town", "[town] spawn", ""));
      sender.sendMessage(
          ChatTools.formatCommand(
              TownySettings.getLangString("admin_sing"),
              "/townyadmin town",
              "[town] outpost #",
              ""));

      return;
    }

    try {

      Town town = TownyUniverse.getDataSource().getTown(split[0]);

      if (split.length == 1) {
        TownyMessaging.sendMessage(getSender(), TownyFormatter.getStatus(town));
        return;
      }

      if (!TownyUniverse.getPermissionSource()
          .testPermission(
              player,
              PermissionNodes.TOWNY_COMMAND_TOWNYADMIN_TOWN.getNode(split[1].toLowerCase())))
        throw new TownyException(TownySettings.getLangString("msg_err_command_disable"));

      if (split[1].equalsIgnoreCase("add")) {
        /*
         * if (isConsole) { sender.sendMessage(
         * "[Towny] InputError: This command was designed for use in game only."
         * ); return; }
         */
        TownCommand.townAdd(getSender(), town, StringMgmt.remArgs(split, 2));

      } else if (split[1].equalsIgnoreCase("kick")) {

        TownCommand.townKickResidents(
            getSender(),
            town.getMayor(),
            town,
            TownyUniverse.getValidatedResidents(getSender(), StringMgmt.remArgs(split, 2)));

      } else if (split[1].equalsIgnoreCase("delete")) {

        TownyUniverse.getDataSource().removeTown(town);

      } else if (split[1].equalsIgnoreCase("rename")) {

        if (!NameValidation.isBlacklistName(split[2])) {
          TownyUniverse.getDataSource().renameTown(town, split[2]);
          TownyMessaging.sendTownMessage(
              town,
              String.format(
                  TownySettings.getLangString("msg_town_set_name"),
                  ((getSender() instanceof Player) ? player.getName() : "CONSOLE"),
                  town.getName()));
        } else
          TownyMessaging.sendErrorMsg(getSender(), TownySettings.getLangString("msg_invalid_name"));

      } else if (split[1].equalsIgnoreCase("spawn")) {

        TownCommand.townSpawn(player, StringMgmt.remArgs(split, 2), town, "", false);

      } else if (split[1].equalsIgnoreCase("outpost")) {

        TownCommand.townSpawn(player, StringMgmt.remArgs(split, 2), town, "", true);
      }

    } catch (NotRegisteredException e) {
      TownyMessaging.sendErrorMsg(getSender(), e.getMessage());
    } catch (TownyException e) {
      TownyMessaging.sendErrorMsg(getSender(), e.getMessage());
    }
  }
Ejemplo n.º 6
0
 public void townLeave(Town town) {
   remove(town);
   TownyMessaging.sendGlobalMessage(TownySettings.getWarTimeForfeitMsg(town.getName()));
   checkEnd();
 }