Time left counter?

Discussion in 'Plugin Development' started by born2kill_, Aug 5, 2014.

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

    born2kill_

    I'm coding a LMS event (Last Man Standing) and I have everything working, but when an admin issues the /lms start command, there is a 1 minute timer before it starts. I want to broadcast when theres 30, 15, 3, 2, and 1 second left. Heres my code:
    Code:
    private static void startTimer() {
    lmsWaitingStage = true;
    Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(WarfareKits.getPlugin(), new Runnable() {
      @Override
      public void run() {
      if(waiting.size() == 1 || waiting.size() == 0) {
      Bukkit.getServer().broadcastMessage(ChatColor.RED + "LMS failed to start because no one joined!");
      lmsStart = false;
      lmsWaitingStage = false;
      return;
      }
     if(started.size() == 0) {
      return;
      } 
      for(Player inLms : waiting) {
      started.add(inLms);
      Bukkit.getLogger().info(inLms.getName());
      }
      for(Player playerStartedLms : started) {
      Bukkit.getLogger().info("lms has started and the sioze is: " + started.size());
      playerLmsStart(playerStartedLms);
      playerStartedLms.sendMessage(ChatColor.GREEN + "LMS has started! You have been teleported into the arena!");
      }
      lmsStart = true;
      }
     
    }, 20*60);
    }
    
    How would I make it broadcast a message when theres 30, 15, etc. seconds left?
    Thanks
    -Born2kill.
     
  2. Offline

    mine-care

    Easy, use a repeating task that runs every 1 second, have a into of ex.60 sec every run of the sheduler, decrease the int by 1 and if it is 30 or 10 or whatever broadcast a message

    PS haven't read your code
     
  3. Offline

    born2kill_

    Thanks, i'll try.
     
  4. Offline

    mine-care

Thread Status:
Not open for further replies.

Share This Page