1.8.8 Team prefix and scoreboard colliding

Discussion in 'Spigot Plugin Development' started by M4tt_H4wk, Mar 24, 2020.

  1. So I am trying to create a scoreboard that implements custom player prefixs, health under their name and a sidebar. This is what I have:
    Code (Text):
    public class Test implements Listener {
        @EventHandler
        public void onJoin(PlayerJoinEvent e) {
            create(e.getPlayer());
        }


        public void create(Player p) {
            //create scoreboard for every player who joins so everyone can have a different scoreboard
            ScoreboardManager manager = Bukkit.getScoreboardManager();
            Scoreboard board = manager.getNewScoreboard();
            //register teams
            Team red = board.registerNewTeam("Red");
            Team blue = board.registerNewTeam("blue");
            //Add prefixs to teams
            red.setPrefix(ChatColor.RED + "[Red] ");
            blue.setPrefix(ChatColor. BLUE + "[Blue] ");
            //get health to put above head
            Objective o = board.registerNewObjective("showhealth", "health");
            o.setDisplaySlot(DisplaySlot.BELOW_NAME);
            o.setDisplayName(ChatColor.RED + "❤");
            //Get which team to put player in to
            if(p.hasPermission("red")) {
                red.addPlayer(p);
            } else {
                red.removePlayer(p);
            }
            if(p.hasPermission("blue")) {
                blue.addPlayer(p);
            } else {
                blue.removePlayer(p);
            }
            //Add sidebar scoreboard
            Objective objective = board.registerNewObjective("Scoreboard", "dummy");
            objective.setDisplaySlot(DisplaySlot.SIDEBAR);
            objective.setDisplayName(ChatColor.AQUA + "test");
            //add stuff to scoreboard
            Score score = objective.getScore("kills");
            score.setScore(1);
            //add player to the scoreboard
            p.setScoreboard(board);
        }
    }
    So when a player joins, a scoreboard is created which gives them a personal sidebar and health. However, in the tab playerlist, it only shows your own name. I understand this is due to having multiple scoreboards for different people however I need a way to implement both player prefixs and a sidebar in my plugin.

    I would appreciate any help :)