Counting down with a delay?

Discussion in 'Plugin Development' started by techboy291, Oct 16, 2012.

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



    So in my plugin, I want the server to broadcast a count down starting by ten. The problem is, I want there to be a delay by one second in between messages. Normally, if I wasn't doing this for Minecraft, I would use Thread.sleep(1000), but since that would glitch out the server, I don't want to do that. So what do you think the best way to do this would be? Would I use the Bukkit Scheduler? If so, how?
  2. Offline


    Yes, (async) scheduled tasks should work for that.
    -> How to use the Scheduler

    Create an Integer which will work as counter and every time you send the remaining seconds decrease this by one and reschedule the task if counter != 0
  3. Offline

    ZeusAllMighty11 Retired Staff

    I used a repeated task, make an int like "int seconds = 500;" then I'd just do "Main.seconds--;" , set scheduler timer to " 20L, 0 " // Which means every 1 second it runs, and then I used a switch statement to broadcast on certain times.
    case 499: // do stuff
  4. Offline


Thread Status:
Not open for further replies.

Share This Page