use scoreboards to modify nametag colours

Discussion in 'Plugin Development' started by Kyorax, Aug 30, 2015.

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

    Kyorax

    Hi everyone,
    I have assigned all players one of two teams and now I need them
    to see the enemy nametags as red and the nametags of their allies as green.
    I've been told this is possible with scoreboards, but I'm not sure how to use them to accomplish that.
    I have already discovered Bukkit.getScoreboardManager.getNewScoreboard(), but what do I have to do next?
    I don't want any code, just instructions on what to do next to accomplish different colours per player.

    Thanks a lot in advance.
     
  2. Offline

    Zombie_Striker

    @Kyorax
    If you want the player's name that's above their head to be coloured, you would need to deal with packets. You would use scoreboards if you want the name in the scoreboard to be coloured.
     
  3. Offline

    Shortninja66

    Are you talking about the name above a player's head? You can do this by changing the display slot to "DisplaySlot.BELOW_NAME".
     
  4. Offline

    blablubbabc

    If you want players from different teams see different name colors for a player ('allies green, enemies red' depends on which team the viewing player is in), you need at least 2 scoreboards if you have 2 teams (sadly):

    * Create 2 scoreboards (sb1 and sb2).
    * Create 2 scoreboard-teams on each of those scoreboards (sb1-allies, sb1-enemies, sb2-allies, sb2-enemies), and setup the colors so the sb1-allies and sb2-allies are green and sb1-enemies and sb2-enemies are red.
    * Now assign the players of each of your 2 teams to one of those scoreboards, ex. players from team1 get assigned to sb1, and players from team2 to sb2.
    * For each of your 2 teams determine the allies and enemies and add them to the corresponding scoreboard team: the allies of team1 will be added to sb1-allies, the enemies of team1 to sb1-enemies, the allies of team2 to sb2-allies and the enemies of team2 to sb2-enemies.
    * Done.

    As the players of your 2 teams are now using different scoreboards, you can have each team see the color for one player differently.

    However, this comes with the disadvantage that you have to add every player to multiple scoreboard-teams (to 1 team on every of your scoreboards), and you also have to apply scoreboard changes to all of those scoreboards, for example in case that you want both teams to see the same scores on their sidebar.
    And in case you ever have more teams, you will need more scoreboards (and twice that many additional scoreboard-teams in total).
    In case you not only want per-team views, but per-player views, you will need to give every player its own scoreboard and add every player to some team on every player-individual scoreboard. Though I have no idea if the overhead for this, on a server with many players, would result in problems then..
     
    Last edited: Aug 30, 2015
    Kyorax and Konato_K like this.
  5. Offline

    Konato_K

    @Zombie_Striker Scoreboards change nametags as well, of course, they only append text at the start or after the name.

    @Shortninja66 No, a simple team would do.
     
    Shortninja66 likes this.
  6. Offline

    Kyorax

    @blablubbabc Thank you very much, that was very detailed and helpful. I coded it that way, so far there are no errors.
    I was only able to test it alone so far, but I am already shown the right colour for my team, I'm confident it will work the other way around, too :)
     
Thread Status:
Not open for further replies.

Share This Page