How do i do a countdown? Say in a tips plugin

Discussion in 'Plugin Development' started by NoEffex, Nov 1, 2012.

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

    NoEffex

    Hey guys,

    Still kinda new to development, and it's gotten to the point that i wanna manage a countdown say for automated broadcasts, how would i do this?
     
  2. Offline

    fireblast709

  3. Offline

    pzxc

    something like:

    Code:
    getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
      int clock = 120;
      public void run() {
        if (clock < 0) return;
        if (clock < 10 || clock % 10 == 0) getServer().broadcastMessage(clock + " seconds left!");
        clock--;
      }
    }, 1L, 20L);
    
     
  4. Offline

    Metal Julien

    Maybe a timer?

    Code:
    Integer counter = 10;
     
    TimerTask task = new TimerTask() {
                public void run() {
                counter = -1;
                bukkit.BroadcastMessage("Starts in " + counter + " seconds");
     
                if (counter <= 0) { timer.cancel(); }
     
                }
        };
                timer.scheduleAtFixedRate(task, 1000, 1000);
     
  5. Offline

    NoEffex

    Ok, thanks guys. Looks good.
     
Thread Status:
Not open for further replies.

Share This Page