コード例 #1
0
ファイル: War.java プロジェクト: adegie/Towny
 public void setupDelay(int delay) {
   if (delay <= 0) start();
   else {
     for (Long t : TimeMgmt.getCountdownDelays(delay, TimeMgmt.defaultCountdownDelays)) {
       // Schedule the warnings leading up to the start of the war event
       // warTimer.schedule(
       //              new ServerBroadCastTimerTask(plugin,
       //                              String.format("War starts in %s",
       // TimeMgmt.formatCountdownTime(t))),
       //                              (delay-t)*1000);
       int id =
           plugin
               .getServer()
               .getScheduler()
               .scheduleAsyncDelayedTask(
                   getPlugin(),
                   new ServerBroadCastTimerTask(
                       plugin, String.format("War starts in %s", TimeMgmt.formatCountdownTime(t))),
                   TimeTools.convertToTicks((delay - t)));
       if (id == -1) {
         TownyMessaging.sendErrorMsg("Could not schedule a countdown message for war event.");
         end();
       } else addTaskId(id);
     }
     // warTimer.schedule(new StartWarTimerTask(universe), delay*1000);
     int id =
         plugin
             .getServer()
             .getScheduler()
             .scheduleAsyncDelayedTask(
                 getPlugin(), new StartWarTimerTask(universe), TimeTools.convertToTicks(delay));
     if (id == -1) {
       TownyMessaging.sendErrorMsg("Could not schedule setup delay for war event.");
       end();
     } else addTaskId(id);
   }
 }
コード例 #2
0
ファイル: TownyUniverse.java プロジェクト: MrNaikito/towny
 public void toggleDailyTimer(boolean on) {
   if (on && !isDailyTimerRunning()) {
     long timeTillNextDay = TownyUtil.townyTime();
     TownyMessaging.sendMsg(
         "Time until a New Day: " + TimeMgmt.formatCountdownTime(timeTillNextDay));
     dailyTask =
         getPlugin()
             .getServer()
             .getScheduler()
             .scheduleAsyncRepeatingTask(
                 getPlugin(),
                 new DailyTimerTask(this),
                 MinecraftTools.convertToTicks(timeTillNextDay),
                 MinecraftTools.convertToTicks(TownySettings.getDayInterval()));
     if (dailyTask == -1) TownyMessaging.sendErrorMsg("Could not schedule new day loop.");
   } else if (!on && isDailyTimerRunning()) {
     getPlugin().getServer().getScheduler().cancelTask(dailyTask);
     dailyTask = -1;
   }
   setChangedNotify(TOGGLE_DAILY_TIMER);
 }