Solved Showing team members

Discussion in 'Spigot Plugin Development' started by finnbon, Mar 31, 2017.

  1. Hello people!

    Let me get straight to the point. I'm working on a team based minigame, and of course, I want to show the players which players are their team members. I could do this via for example, a scoreboard at the side of the screen, which I will try, but I'm still very unexperienced with scoreboards. Besides that, I'd like an in game way to show the team members. For example, a team color above their head, or something like that. How do you show team members? What is the best way in your opinion?

    The best way in my opinion would be to color their name tags above their head, but I have no idea how to do this. A little help on this part would be highly appreciated! :)

    Thanks in advance!

    - Finn
  2. You should register scoreboard teams, and then add a colorcode as prefix.
  3. Are you trying to show only the team members their own colors, for example:

    Groups: a, b, c and d, each team would see their mates in Green while the enemies are red?

    Id register a team for each group in the scoreboard, then send a team update packet to each player updating their team mates prefix to whatever you needed,

    Go through this for a bit more info or use Protocol lib but ive never used that lib so i cant help from there
  4. The idea of showing enemies in red and allies in green sounds cool, but I'd like to avoid ProtocolLib & packets as much as possible, so I'd like to go with coloring their names in the color of their own teams.

    I'm just rather confused of how a scoreboard team works. As well as scoreboard objectives etc. Do you know of any good tutorial somewhere which explains objectives and teams? If not I'll start looking myself.
  5. I see, well you wont need to deal with packets if you only want to change prefix colors, all you do is:

    - Team team = scoreboard.registerNewTeam(String name);
    - team.setPrefix(String name); //Has a 16 char limit includes chatcolors
    - team.addEntry(String playerName);

    Everyone added to that team would have the prefix on their nametag as well as their tablist, so if you chose a prefix named ("&c[Sweg]&r"), the users name would show as [Sweg] coolPlayer

    As for objectives, these were a pain in the ass for me when learning as Minecraft doesnt support multiple objectives to be used per person which means one scoreboard only supports one set of scores for every member in it, i found that using packets made it much easier to deal with this problem as i have control and can change the scores according to who is receiving them, allowing me to have everyone on one scoreboard with different teams but still get unique scores, upto you if you need this though it gets quite complicated and you'll need to write your own scoreboard handler to make things easier.
    • Like Like x 1
  6. Heres a small example to help you get started, terribly sorry about the formatting, nothing much i could do about it in PasteBin
    • Like Like x 1
    • Friendly Friendly x 1
  7. As far as I know, only the player with that scoreboard sees that prefix, because the teams are per scoreboard :)

    And I formatted it for you:
  8. Thats why id make the scoreboard object an instance variable so you can use it later for other players, thanks for the formatting :)
    • Friendly Friendly x 1
  9. Thanks guys! I think I'll get it to work now. :)
    • Like Like x 1