Nametag colors

Discussion in 'Plugin Development' started by fanofrods, Jul 24, 2015.

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

    fanofrods

    Is there anyone that knows how to set a player's above head nametag with a color?

    After some search with absolute no clue, this is what I got, but it didn't work.

    Code:
    public static Team sc;
    Code:
           
        public static void Nametag(Player p, String cc) {
           try {
              Scoreboard sb = Bukkit.getScoreboardManager().getMainScoreboard();
              Team c = sb.getTeam(p.getName());
              if (c == null) {
                  c = sb.registerNewTeam(p.getName());
              }
              c.setPrefix('ยง' + cc);
              c.addPlayer(p);
              p.setScoreboard(sb);
              sc = c;
           } catch (NullPointerException localNullPointerException) {}
        }
    
    I've heard of packets, but never used them.

    Help is appreciated as always!
    Thanks,
    -Fan
     
  2. Offline

    Hawktasard

    @fanofrods
    Check out TagAPI. I'm pretty sure that's what it's called. @md_5 made it.
    I haven't used it since like a year ago, but it should work.
     
  3. Offline

    Nic2555

    The function is called setCustomName() I think. You can une chat color properties on it. I know it work on living entities, but I never tested it on player. Buy like @Hawktasard said, tagAPI works fine
     
  4. Offline

    fanofrods

    I don't want to use an API though. :C
     
  5. Offline

    Nic2555

    Then try using the setCustomName() function.
     
  6. Offline

    fanofrods

    setCustomName() does not work for players.

    I heard something about a scoreboard API in Bukkit that lets you do it. Any idea?
     
  7. Offline

    Nic2555

    The scoreboard can be display under a player's name. But it won't override it.

    So you will have both, the name of the player plus the one you want to display

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 11, 2016
  8. Offline

    fanofrods

    TagAPI doesn't work with 1.8 I think
    + Some people says it's possible to use the new scoreboard bukkit API for nametags
     
  9. Offline

    567legodude

    @fanofrods Create a team. Then set the prefix of the team to a color. Add players to the team, any player on the team can see the color above your head.
     
Thread Status:
Not open for further replies.

Share This Page