Teams were not set

Discussion in 'Spigot Help' started by Maxrisko, May 14, 2022.

  1. Code (Java):
    public class ScoreboardManager{
       
        public static void registerScoreboard(Player p) {
            Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
           
            org.bukkit.scoreboard.Team teamBlue = board.registerNewTeam("TeamBlue");
            org.bukkit.scoreboard.Team teamRed = board.registerNewTeam("TeamRed");
            org.bukkit.scoreboard.Team teamYellow = board.registerNewTeam("TeamYellow");
            org.bukkit.scoreboard.Team teamGreen = board.registerNewTeam("TeamGreen");
           
            teamBlue.setPrefix(ChatColor.AQUA.toString() + "§bBLUE ");
            teamRed.setPrefix(ChatColor.RED.toString() + "§cRED ");
            teamYellow.setPrefix(ChatColor.YELLOW.toString() + "§eYELLOW ");
            teamGreen.setPrefix(ChatColor.GREEN.toString() + "§aGREEN ");
           
            if(Team.getTeam(p) == BlockGame.blueTeam) {
                teamBlue.addEntry(p.getName());
               
            }else if(Team.getTeam(p) == BlockGame.redTeam) {
                teamRed.addEntry(p.getName());
            }else if(Team.getTeam(p) == BlockGame.yellowTeam) {
                teamYellow.addEntry(p.getName());
            }else if(Team.getTeam(p) == BlockGame.greenTeam) {
                teamGreen.addEntry(p.getName());
            }
           
            for(Player all : Bukkit.getOnlinePlayers()) {
                all.setScoreboard(board);
            }
           
        }
       

    }
    Code (Java):
    public static void assignTeam(Player p) {
            ArrayList<Team> teamList = new ArrayList<>(Arrays.asList(blueTeam,redTeam));
            int teamLimit = (int) Math.ceil((GameManager.alivePlayer.size() / 2.0));
            for(Player alive : GameManager.alivePlayer) {
                int teamNumber = Randomizer.getRandomInt(teamList.size() - 1);
                Team.addPlayers(teamList.get(teamNumber), alive);
                if(Team.getTeamAmount(teamList.get(teamNumber)) >= teamLimit) {
                    teamList.remove(teamList.get(teamNumber));
                }
                Bukkit.broadcastMessage(Team.playerTeams.get(alive.getName()).teamColor + " " + alive.getName());
            }
            for(Player all : Bukkit.getOnlinePlayers()) {
                ScoreboardManager.registerScoreboard(all);
            }
            setUP(p);
        }