NameTags with scoreboards

Discussion in 'Spigot Plugin Development' started by FatP, Sep 15, 2019.

  1. Hello,

    how do i add the prefix / suffix thingy with the scoreboards?
    I tried it a bid but it only showed it's own name.

    I would like to expand the name limit to 48 so other players can see the rank and prefix of it.

    Thank you for the help :)
     
  2. getTeam#setPrefix is what you are looking for
     
  3. Code (Text):
    player.getScoreboard().getTeam().setPrefix("");
    Doesn't work as it gives me a red mark at "getTeam" saying:
    http://prntscr.com/p6h45w
     
  4. Your IDE says you everything you need to know. getTeam# requires a String as it states on your screenshot.
     
  5. What should i add in there?
    Maybe? a new Team Name or?
    ._.
     
    1. Register a new team
    2. Get the team using getTeam#
    3. Add the player to the team
    4. Set the scoreboard for the player
     
    • Like Like x 1
  6. I think you're looking for any like this:

    Code (Java):
    Team team = scoreboard.getTeam("teamname") == null ? scoreboard.registerNewTeam("teamname") : scoreboard.getTeam("teamname");
    team.setPrefix("prefix");
    team.setSuffix("suffix");
    if (!team.hasEntry("playername")) {
      team.addEntry("playername");
    }
     
  7. Are you able to disable the Tab function?
    So that it only updates the player name?