Solved Timer? lol

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

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

    Ty Cleere

    I am trying to use a dragon bar to show a timer. But it doesnt count down like i am thinking it should. I got it to display the right stuff but it isnt counting down. When i just use the int countdown it works fine but with i use the int m and s it doenst work. here is code and a pic

    Code:java
    1. @EventHandler
    2. public void startBar(final Player[] players) {
    3. Bukkit.getScheduler().scheduleSyncRepeatingTask(
    4. Bukkit.getPluginManager().getPlugin("UHC-Essentials"),
    5. new Runnable() {
    6.  
    7. @Override
    8. public void run() {
    9. BarAPI.setMessage("Time left: " + m + " minutes " + s
    10. + " seconds", 5400);
    11.  
    12. if (m == 75) {
    13. Bukkit.broadcastMessage("§3[UHC] §6PvP is now enabled!!!");
    14. Bukkit.getWorld("reddit").setPVP(true);
    15. }
    16. if (countdown == 10) {
    17. Bukkit.broadcastMessage("§3[FreezeTag] §6Game starting in §b"
    18. + countdown + " §6seconds");
    19. }
    20. if (countdown <= 5 && countdown > 0) {
    21. Bukkit.broadcastMessage("§3[FreezeTag] §6Game starting in §b"
    22. + countdown + " §6seconds");
    23. }
    24. if (countdown <= 5) {
    25. for (Player p : Bukkit.getOnlinePlayers()) {
    26. p.playSound(p.getLocation(), Sound.NOTE_STICKS,
    27. 1, 0);
    28. }
    29. }
    30. countdown--;
    31. if (countdown < 0) {
    32. Bukkit.getPluginManager()
    33. .getPlugin("UHC-Essentials").getServer()
    34. .getScheduler().cancelAllTasks();
    35. for (Player p : Bukkit.getOnlinePlayers()) {
    36. p.playSound(p.getLocation(),
    37. Sound.ENDERDRAGON_GROWL, 1, 0);
    38. }
    39. }
    40.  
    41. }
    42.  
    43. }, 0L, 20L);


    2014-04-27_11.19.46.png
     
  2. Offline

    CraftedShack

    You have countdown--; which will -1 from countdown every second. but you also need to add s--; every second and m--; every minute.
     
  3. Offline

    garbagemule

    Relevant post: Clicky

    Don't make things harder than they have to be, and you'll have a much easier time reasoning about your code.
     
  4. Offline

    Ty Cleere

Thread Status:
Not open for further replies.

Share This Page