Solved Bukkit runnable

Discussion in 'Spigot Plugin Development' started by tatemylove, Apr 17, 2017.

  1. I got the bukkit runnable to run when there are enough players in the queue, but it spams the chat and the time won't decrease.
    Code (Text):
    public static int timeUntilStart;
    Main plugin;
    public GameCountDown(Main pl){
        plugin = pl;
    }

        @Override
        public void run() {
            timeUntilStart = 60;
            if(timeUntilStart == 0){
                if(Main.WaitingPlayers.size() < Main.minplayers){
                    plugin.stopCountDown();
                    for(Player p : Main.WaitingPlayers){
                        p.sendMessage(Main.msprefix + "┬žcNot enough players!");
                    }
                    return;
                }
                BBDArena.start(Integer.toString(getArena.getCurrentArena()));
                BBDArena.assignTeam(Integer.toString(getArena.getCurrentArena()));
                BaseArena.States = BaseArena.states.STARTED;
            }
                if (timeUntilStart % 10 == 0 || timeUntilStart < 0) {
                    for (Player p : Main.WaitingPlayers) {
                        p.sendMessage(Main.msprefix + timeUntilStart + "┬ždseconds until start!");
                        break;
                    }
                }
            timeUntilStart -= 1;
        }
     
    #1 tatemylove, Apr 17, 2017
    Last edited: Apr 17, 2017
  2. You're setting timeUntilStart to 60 every time it's run. It will perpetually be 60, then decrement to 59.
     
  3. Alright thanks bro, I deleted the timeUntilStart = 60; and changed public static int timeUntilStart = 60;

    Now the runnable seems to be working properly
     
  4. Please mark the thread as solved. If your problem is fixed.