Countdown Problem

Discussion in 'Plugin Development' started by whitebradcam, May 29, 2014.

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

    whitebradcam

    I am working on a plugin and my countdown used to work but now can't. If you see a problem please leave a reply.

    Code:java
    1. package com.bomb.threads;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5.  
    6. import com.bomb.handlers.Game;
    7. import com.bomb.utils.ChatUtilities;
    8. import com.bomb.utils.GameState;
    9.  
    10. public class StartCountdown implements Runnable{
    11.  
    12. private static int timeUntilStart;
    13.  
    14. public void run() {
    15. timeUntilStart = 90;
    16. while(true) {
    17. if(GameState.isState(GameState.IN_LOBBY))
    18. if (Game.canStart()) {
    19. timeUntilStart = 90;
    20. ChatUtilities.broadcast(ChatColor.GREEN + "You have enough players to play bomb!");
    21. for(; timeUntilStart >= 0; timeUntilStart--) {
    22. if(!Game.canStart()){
    23. ChatUtilities.broadcast(ChatColor.GREEN + "You seem to not have enough players, we will reset the timer while you get some more people.");
    24. break;
    25. }
    26. if(timeUntilStart == 0) {
    27. Game.start();
    28. break;
    29. }
    30.  
    31. if(timeUntilStart % 10 == 0 || timeUntilStart < 10) {
    32. ChatUtilities.broadcast(timeUntilStart
    33. + " seconds until the game starts!");
    34. }
    35.  
    36. try {
    37. Thread.sleep(1000);
    38. } catch(InterruptedException e) {
    39. e.printStackTrace();
    40. Bukkit.shutdown();
    41. }
    42. }
    43.  
    44. }
    45. try{
    46. Thread.sleep(1000);
    47. e.printStackTrace();
    48. Bukkit.shutdown();
    49. }
    50.  
    51. }
    52. }
     
  2. Offline

    turqmelon

    What do you mean it doesn't work? Nothing happens, or you get an error? If you get an error, can you share it here?
     
  3. Offline

    teej107

    whitebradcam Is this in the main thread? Why don't you use
    Code:java
    1. Bukkit.getScheduler().scheduleSyncRepeatingTask(arg0, arg1, arg2, arg3);
    ?
     
  4. Offline

    whitebradcam


    Nothing happens

    where?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 1, 2016
Thread Status:
Not open for further replies.

Share This Page