I am currently making a Minecraft SkyWars-Plugin and want to make a better looking tablist.
The Problem:
Lets say you have PlayerA and PlayerB. If PlayerA looks on the tablist, his name should be green and the name of PlayerB should be red.
But if PlayerB looks at his tablist, PlayerB's name should be green and PlayerA's name should be red.
So basically your own name should be marked as green (Color code 'a') and the opponents should have a red name (Color code 'c').
How do I achieve that? Do I send packages to each Player for his tablist? If so, which packages should/can I use?
Your problem can be solved in two ways.
If you want to show per-player visible colors only in a tablist, you can use Player Info
packet (specification https://wiki.vg/Protocol#Player_Info) for tablist content modification. Full valid code can be very volume, so i give you an algorithm (below I mean "packet" is Player Info
packet):
remove player
(see wiki for action list) with PlayerA.uuid to PlayerAremove player
with PlayerB.uuid to PlayerAadd player
, PlayerA.uuid and colored PlayerA's display name for PlayerA (which in your case is green) to PlayerA.add player
, PlayerB.uuid and colored PlayerB's display name for PlayerA (which in your case is red) to PlayerA.For packets management you can use ProtocolLib plugin.
If you want to show per-player visible colors in tablist and above the head, you can use similar algorithm with scoreboard teams packets. Or you can try to find implemented plugin api for per-player visible prefixes.