Timer in scoreboard?

Discussion in 'Plugin Development' started by Ty Cleere, Apr 25, 2014.

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

    Ty Cleere

    I was wondering how to set a timer in a scoreboard. i have this set up but i dont know how to get the timer in the display of the scoreboard?

    Code:java
    1. if (commandLabel.equalsIgnoreCase("uhctimer")) {
    2. if (!sender.hasPermission("uhc.timer")) {
    3. sender.sendMessage(ChatColor.DARK_RED
    4. + "YOU DONT HAVE PERMISSION TO DO THIS!");
    5. return true;
    6. }
    7.  
    8. ScoreboardManager m = Bukkit.getScoreboardManager();
    9. Scoreboard timer = m.getNewScoreboard();
    10.  
    11. Objective obj = timer.registerNewObjective("timer",
    12. "deathCount");
    13. obj.setDisplaySlot(DisplaySlot.SIDEBAR);
    14. obj.setDisplayName(ChatColor.RED + "Time Left");
    15.  
    16. for (Player online : Bukkit.getWorld("reddit").getPlayers()) {
    17. online.setScoreboard(timer);
    18. }
    19. player.sendMessage(ChatColor.RED
    20. + "You have started the uhc timer!");
    21.  
    22. }
     
  2. Offline

    Gater12

    Ty Cleere
    You're going to have to schedule a repeating task for the timer to count down and the scoreboard to update to display the time.
     
    Ty Cleere likes this.
  3. Offline

    Ty Cleere

    Gater12 Ok. How would i set that for the scoreboard to display?
     
  4. Offline

    BillyBobJoe168

    You register a score and make an int. Every second, subtract one from this int and set it as the score.
     
Thread Status:
Not open for further replies.

Share This Page