ScoreBoard countdown

Discussion in 'Plugin Development' started by razlooslav, Aug 14, 2019.

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

    razlooslav

    Hi, I have scoreboard with countdown to start game, all is working, but if player quit server and join again, get new scoreboard, and countdown will start again

    Here is my code of scoreboard:
    Code:
        private void LobbyScoreboard(Player p) {
       
            final Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
            final Objective obj = board.registerNewObjective("lobby", "dummy");
    
            obj.setDisplaySlot(DisplaySlot.SIDEBAR);
            obj.setDisplayName("§c§lIN LOBBY");
    
    
            Team space3 = board.registerNewTeam("space3");
    
            space3.addEntry(ChatColor.GOLD.toString());
            space3.setPrefix("   ");
            obj.getScore(ChatColor.GOLD.toString()).setScore(6);
    
            Team vyberteam = board.registerNewTeam("teamtimer");
            Team status = board.registerNewTeam("statustimer");
            Team teamtablist = board.registerNewTeam("tablistteam");
    
                teamtablist.setPrefix("" + Teams.getteamcolor(p));
                teamtablist.addPlayer(p);
           
                status.addEntry(ChatColor.YELLOW.toString());
                status.setPrefix("Status: ");
                obj.getScore(ChatColor.YELLOW.toString()).setScore(5);
    
                Team space = board.registerNewTeam("space");
    
                space.addEntry(ChatColor.DARK_PURPLE.toString());
                space.setPrefix(" ");
                obj.getScore(ChatColor.DARK_PURPLE.toString()).setScore(4);
    
                vyberteam.addEntry(ChatColor.GREEN.toString());
                vyberteam.setPrefix("Team: ");
                obj.getScore(ChatColor.GREEN.toString()).setScore(3);
    
                Team space2 = board.registerNewTeam("space2");
    
                space2.addEntry(ChatColor.DARK_AQUA.toString());
                space2.setPrefix("  ");
                obj.getScore(ChatColor.DARK_AQUA.toString()).setScore(2);
           
           
                new BukkitRunnable(){
                    int counter2 = 31;
                    int counter = 1;
                    @Override
                    public void run() {
                        counter++;
                   
                        if(SH_GS.getState() == State.CEKA) {
                   
                   
                        }else {
                            counter2--;
                            obj.setDisplayName("§c§lIN LOBBY §f|§a " + counter2 + "s"); //and for the fake timer
                        }
    
                        if(counter == 0){
                            cancel();
                        }
                        board.getTeam("statustimer").setSuffix("§a" + SH_GS.GetStatusName());
                        board.getTeam("tablistteam").setPrefix("" + Teams.getteamcolor(p));
                        teamtablist.addPlayer(p);
                   
                   
                        board.getTeam("teamtimer").setSuffix("§a" + Teams.getTeam(p));
                       
                        if(SH_GS.getState() == State.VE_HRE) {
                            this.cancel();
                        }
                   
                    }
                }.runTaskTimer(this, 0L, 20L);
    
            for(Player people: Bukkit.getOnlinePlayers()){
                people.setScoreboard(board);
            }
        }

    Any solution?
     
  2. Offline

    tlm920

    Im not sure what your question is, do you want players to get a scoreboard and start the countdown again or do you want to set the countdown to what it was before.
     
Thread Status:
Not open for further replies.

Share This Page