Countdown Timer

Discussion in 'Plugin Development' started by BurnBlader, Nov 4, 2012.

Thread Status:
Not open for further replies.
  1. I'm trying to make it so that you do /go and there's a timer that goes 2 minutes then 1 minute then 30 seconds then countdown from 10. I'd like it to be 2 minutes long.
     
  2. Offline

    Vandrake

    use modul here. %<<<<
    if timer % 90(1.30m) == 0 //this means its 1.30 min. this when its above 10 else every second
     
  3. Offline

    ZeusAllMighty11

    Code:
     
    int seconds = 120;
     
    int taskID = myPlugin.getServer().getScheduler().scheduleAsyncRepeatingTask(myPlugin, new Runnable() {
     
       public void run() {
            switch(seconds){
                case 119: Bukkit.brodcastMessage("2 minutes"); // about 2 minutes
                 break;
                
                case 60: Bukkit.brodcastMessage("1 minute"); // 1 min
                break;
                case 30: Bukkit.brodcastMessage("30 seconds"); 
                break;
     
     
     
     
                case 15: Bukkit.brodcastMessage("30 seconds"); 
     
                break;
     
     
     
            }
            seconds--;
       }
    }, 20L, 0)
    
    etc
     
  4. Offline

    raGan.

    Is broadcast thread-safe ?
     
  5. n, because its an asyn task, only sync task are safe
     
  6. Offline

    raGan.

    I was asking about method itself, because only thread-safe methods should be used in async tasks.
     
  7. broadcast is not thread safe, ZeusAllMighty11 is incorrectly using a bukkit api methode from outside the bukkit main thread
     
  8. Offline

    ZeusAllMighty11

    Not sure what that means, but works fine for me. Haven't had any issues.
     
    tom1000o likes this.
Thread Status:
Not open for further replies.

Share This Page