Run Event at Certain Server Time

Discussion in 'Plugin Development' started by gustebeast, Apr 17, 2013.

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


    What is the best, least resource intensive way to run an event at a particular server time. For example, running "/say Hey Guys", every day at 8:00 a.m.

    One way would of course be to run a check for the server time every minute untill it matched up with "8:00", but is this the least intensive option?

    By "server time" I mean world time, not minecraft time.
  2. Offline


    I tried the Quartz Scheduler for this, but wouldn't recommend it. Anyone have other recommendations/suggestions? I'd like an answer myself.
  3. Offline


    gustebeast HSAR
    The easiest option would be to create a sync task that runs every minute and checks the current server time.
    and if the current time is 8 am or what ever run your code.
    and it would't be a very heavy operation.
  4. Offline


    Certainly the easiest, but not really very efficient - as I'm sure you would agree.
  5. Offline


    No i don't.
    Have a look at what the minecraft server does every tick it is extremely small in comparasion to the lighting and physics updates. if you want me to prove it i could do a micro benchmark.
  6. Offline


    Operations like that are handled by the server thousands of times every tick so it wouldn't be very inefficient. The only more efficiant way would be, to check the server time on start, and run a delayed timer with the delay time equal to the calulated minutes until 8 am,
  7. Offline


    Close, but this still doesnt take into account a server that doesnt restart every 24 hours. It would work for the first day, but then it wouldnt have a start up to reset the timer. You would need to make it so that at 8 a.m, aside from doing whatever task you want it to do, it also sets the timer to 24 hours. If the server never restarts, it would just keep using that timer. If the server does restart it resets it based on the current time.

    This is probably the best way to accomplish the task.
Thread Status:
Not open for further replies.

Share This Page