Want a better Minecraft server? Read about SpigotMC here!
Separate names with a comma.
Discussion in 'Spigot Plugin Development' started by KPidS, Jun 12, 2018.
Hey. Somehow i need to hide player nametag only when you cant actually see him. It is posible?
Yes, but you will need to use scoreboard teams. To hide Player A's username from showing to Player B, Player B needs their own scoreboard and Player A needs to be on a team in that scoreboard. Then, that team needs to have the option enabled that disables nametags from being shown.
Your best bet is to update it on the PlayerMoveEvent (not as bad as some people make out). Try using timings to see how much lag it might cause.
Might require packets, as managing enough teams to work for every player for every other player within render distance could get hectic.
Not really, you can either create a team for each individual player with their username or you can create a single team and add or remove players from it as needed.
Packets would be overkill, especially since (afaik) team packets especially are tough to deal with (especially to make it work with regular non-packet teams).
It might also be possible to place an entity on the player's head, as when a living entity has a custom name but visibility is set to false, their name only shows up when you hover over the entity. Unfortunately, this does not work for players or for invisible entities, so you would have to find an entity with a small hitbox with no texture (or retexture one yourself with a resource pack to be invisible), and add them as a passenger to the player.
However, this may not be the effect you are looking for.
He's not talking about only showing when looking at, though if he was I don't think that would be the best way (you have to get pretty near, and have to look at the hitbox).