Changing name above head using scoreboards

Discussion in 'Spigot Plugin Development' started by bengalman211, Jun 9, 2017.

  1. So this is the method that is called to change the color of the name above a players head. I feel like this is bad because it's creating a new scoreboard and team everytime the method is called, but when attempting to make the scoreboard variables global, errors are thrown. Here is the method, if someone could guide me on how to arrange these statements, that would be amazing :)
    Code (Text):
    public void nameColorChange(Player p) {
            this.getLogger().log(Level.INFO, "Color Change called");
            ScoreboardManager manager = Bukkit.getScoreboardManager();
            Scoreboard board = manager.getNewScoreboard();
            Team escaped = board.registerNewTeam("Escaped");
            escaped.addPlayer(p);
            p.setScoreboard(board);
        }
     
    #1 bengalman211, Jun 9, 2017
    Last edited: Jun 9, 2017
  2. This only changes the tab menu, I'd like to change the color of the name above their head.
     
  3. #3 Yamakaja, Jun 9, 2017
    Last edited: Jun 9, 2017
  4. Oh it appears my OP is missing a line... I was using "escaped.setPrefix(ChatColor.DARK_RED + "");" also and it didn't work which is why I'm stumped, I wrote my OP at 2am and I'm on my phone currently sorry.
     
  5. Or if anyone can reference a good way to do it with packets, I've never done it before and I know you guys don't like to spoon feed though and I'd probably need it lol.