timer

On example you have minigame lobby and you would to inform player how many is to start game. So you have 2 location, first is spawnMinigameLobby(to this location will be rotate chars) and second charsLocation.

    public Integer startTimer(){
        return Bukkit.getServer().getScheduler().
                scheduleSyncRepeatingTask(plugin.getInstance(),
                new Runnable() {
            // there are seconds to start
            int number = 30;
            Integer chars;
            
            public void run() {
                if (number > 0) 
                {
                    if(chars != null) CharUTIL.removeChars(chars);

                    chars = CharUTIL.createChars(charsLocation, 
                    spawnMinigameLobby, true, "&cTo start game is: &4" 
                    + number + " &cseconds!");

                    CharUTIL.buildChars(chars);
                    
                    number--;
                }
                else if(number == 0)
                {
                    CharUTIL.removeChars(chars);

                    chars = CharUTIL.createChars(charsLocation,
                    spawnMinigameLobby, true, 
                    "&2Teleporting to the server game!");

                    CharUTIL.buildChars(chars);

                    // there can be function on example to teleport on 
                    // a bugee migame server
                }       
            }
        }, 0L, 20L);
    }

Comments

Posts Quoted:
Reply
Clear All Quotes