Solved Countdown goes too fast

Discussion in 'Plugin Development' started by Jamez, Jul 8, 2015.

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

    Jamez

    Hi, I have a problem regarding a countdown timer I have. The problem: The first time I initiate it, it goes the perfect speed, 1 second each time, but after I do it again, it goes way faster than the first time. Here's my code:
    Code:
                
        public static int countdown = 31;
    BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
                
                    final String minigametag = ChatColor.AQUA + "[" + ChatColor.RED + "Splat" + ChatColor.AQUA + "] ";
                    final int min = 4;
                    startings.add(i);
                    countdown = getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                        public void run() {
                            int inarenas = inarena(i);
                            countdown--;
                        if(countdown == 30) {
    //Tells everyone there is 30 seconds//
                        }
                        else if(countdown == 20) {
    //Tells everyone there is 20 seconds//
                        }
                        else if(countdown == 10) {
    //Tells everyone there is 10 seconds//
                        }
                        else if(countdown <= 5 && countdown > 0) {
    //Tells everyone there is 5,4,3,2,1 seconds//
                        }
                        else if(countdown == 0){
    //Tells everyone the game is starting//
    }
                        }
                        //Stuff//
                    }
                        }
                        , 0, 20);
     
  2. Offline

    poepdrolify

  3. Offline

    mythbusterma

    @Jamez

    Simple solution: stop abusing the "static" keyword.
     
  4. Offline

    Jamez

    @poepdrolify
    Thanks, that problem is gone, but if more than 1 person is in the server, it speeds up again. I did exactly what you said to do in the tutorial.
     
  5. Offline

    mythbusterma

    @Jamez

    If you stop abusing the static keyword, all your problems will 'magically' go away.
     
    Jamez likes this.
  6. Offline

    Jamez

    No longer using static, I did exactly as his tutorial showed.
    Edit: Fixed, and it has nothing to do with any code on here, thanks @mythbusterma and @poepdrolify
     
    Last edited: Jul 8, 2015
Thread Status:
Not open for further replies.

Share This Page