PacketNameTagTeams

public final class PacketNameTagTeams

Client-only scoreboard teams that keep a living entity's name tag visible to a viewer while something rides that entity. Minecraft hides the name of a team-less vehicle; an entity on a team follows the team's name-tag rule instead, so each kept subject gets a one-member team with nameTagVisibility ALWAYS on the viewer's client only. Mobs still show their name only when it is set visible or looked at, as without a rider. Callers release a subject while it has a real team on the viewer's Bukkit scoreboard.

Other plugins also send teams straight to clients, invisible to the Bukkit scoreboard. Moving their member into our team makes their later "remove this member" packet fail on the client, which disconnects the viewer. So each viewer's packet handler mirrors every team packet the client receives: a subject already on another team is not kept, and an entry our team held is put back into the sender's team just before such a removal reaches the client.

Functions

Link copied to clipboard
public static void clear()
Link copied to clipboard
public static void clearViewer(UUID viewer)
A viewer who left needs no packets; forget what they were shown.
Link copied to clipboard
public static boolean isKept(UUID viewer, UUID subject)
Link copied to clipboard
public static void keep(Player viewer, Entity subject)
Sends the team once per viewer and subject; later calls are free.
Link copied to clipboard
public static List<String> observe(UUID viewer, String team, boolean teamRemoved, boolean playersAdded, boolean playersRemoved, Collection<String> players)
Mirrors a team packet on its way to the viewer's client.
Link copied to clipboard
public static void release(Player viewer, UUID subject)
Link copied to clipboard
public static void releaseSubject(UUID subject)
Lifts the subject's team from every viewer, for a label that goes away.
Link copied to clipboard
public static String scoreboardEntry(Entity subject)
The scoreboard entry Minecraft files the entity under: a player's name, any other entity's UUID string.
Link copied to clipboard
public static String teamName(UUID subject)
Sixteen characters at most, stable per subject.