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); }
public void toggleMobRemoval(boolean on) { if (on && !isMobRemovalRunning()) { mobRemoveTask = getPlugin() .getServer() .getScheduler() .scheduleSyncRepeatingTask( getPlugin(), new MobRemovalTimerTask(this, plugin.getServer()), 0, MinecraftTools.convertToTicks(TownySettings.getMobRemovalSpeed())); if (mobRemoveTask == -1) TownyMessaging.sendErrorMsg("Could not schedule mob removal loop."); } else if (!on && isMobRemovalRunning()) { getPlugin().getServer().getScheduler().cancelTask(mobRemoveTask); mobRemoveTask = -1; } setChangedNotify(TOGGLE_MOB_REMOVAL); }
public void toggleHealthRegen(boolean on) { if (on && !isHealthRegenRunning()) { healthRegenTask = getPlugin() .getServer() .getScheduler() .scheduleSyncRepeatingTask( getPlugin(), new HealthRegenTimerTask(this, plugin.getServer()), 0, MinecraftTools.convertToTicks(TownySettings.getHealthRegenSpeed())); if (healthRegenTask == -1) TownyMessaging.sendErrorMsg("Could not schedule health regen loop."); } else if (!on && isHealthRegenRunning()) { getPlugin().getServer().getScheduler().cancelTask(healthRegenTask); healthRegenTask = -1; } setChangedNotify(TOGGLE_HEALTH_REGEN); }
public void toggleTownyRepeatingTimer(boolean on) { if (on && !isTownyRepeatingTaskRunning()) { townyRepeatingTask = getPlugin() .getServer() .getScheduler() .scheduleSyncRepeatingTask( getPlugin(), new RepeatingTimerTask(this), 0, MinecraftTools.convertToTicks(TownySettings.getPlotManagementSpeed())); if (townyRepeatingTask == -1) TownyMessaging.sendErrorMsg("Could not schedule Towny Timer Task."); } else if (!on && isTownyRepeatingTaskRunning()) { getPlugin().getServer().getScheduler().cancelTask(townyRepeatingTask); townyRepeatingTask = -1; } setChanged(); }