Пример #1
0
  public void start() {
    warTime = true;

    // Announce

    // Seed spoils of war
    try {
      warSpoils.pay(TownySettings.getBaseSpoilsOfWar(), "Start of War - Base Spoils");
      TownyMessaging.sendMsg(
          "[War] Seeding spoils of war with " + TownySettings.getBaseSpoilsOfWar());
    } catch (EconomyException e) {
      TownyMessaging.sendErrorMsg("[War] Could not seed spoils of war.");
    }

    // Gather all nations at war
    for (Nation nation : TownyUniverse.getDataSource().getNations()) {
      if (!nation.isNeutral()) {
        add(nation);
        TownyMessaging.sendGlobalMessage(
            String.format(TownySettings.getLangString("msg_war_join_nation"), nation.getName()));
      } else if (!TownySettings.isDeclaringNeutral()) {
        try {
          nation.setNeutral(false);
          add(nation);
          TownyMessaging.sendGlobalMessage(
              String.format(TownySettings.getLangString("msg_war_join_forced"), nation.getName()));
        } catch (TownyException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }
    }
    // warTimer.scheduleAtFixedRate(new WarTimerTask(this), 0, 1000);
    int id =
        plugin
            .getServer()
            .getScheduler()
            .scheduleAsyncRepeatingTask(
                getPlugin(), new WarTimerTask(this), 0, TimeTools.convertToTicks(5));
    if (id == -1) {
      TownyMessaging.sendErrorMsg("Could not schedule war event loop.");
      end();
    } else addTaskId(id);
    checkEnd();
  }
Пример #2
0
 public void add(Nation nation) {
   for (Town town : nation.getTowns()) add(town);
   warringNations.add(nation);
 }