Timer Keep Going When Server Restarts

Discussion in 'Plugin Development' started by 8thDimension, Aug 11, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    8thDimension

    I don't know if this makes any sense or even if it is possible, but lets say I start a timer with a command that will last for a few minutes (I'm using Scheduler's by the way) but then the server restarts (Like how some servers have automatic reboots)

    How would I make it so that the timer will continue after the restart? Sorry if this is asked a lot or if it's a "newb question"

    Thanks in advance :D
     
  2. Offline

    bergerkiller

    Stop the timer in onDisable and start it again in onEnable. As reload/restart suggests, it restarts. So all variables (local or static) will be cleared from memory. If the timer should always be run in onEnable, then just run it. If it only has to run in certain circumstances you have to store a file/configuration that suggests this.

    Simpler: you could simply check if "runtimer.tmp" exists and create/remove this file accordingly. (no writing to this file at all)
     
  3. Offline

    masteroftime

    Write the time when the timer should finish to a file in onDisable(). Then you can calculate the time again when the server restarts in onEnable().
     
  4. Offline

    8thDimension

Thread Status:
Not open for further replies.

Share This Page