diff --git a/src/main/java/net/william278/velocitab/api/VelocitabAPI.java b/src/main/java/net/william278/velocitab/api/VelocitabAPI.java index e0f2aeb..336b48a 100644 --- a/src/main/java/net/william278/velocitab/api/VelocitabAPI.java +++ b/src/main/java/net/william278/velocitab/api/VelocitabAPI.java @@ -163,6 +163,18 @@ import java.util.Optional; plugin.getVanishManager().unVanishPlayer(player); } + /** + * Retrieves the server group that the given player is connected to. + * + * @param player the player for whom to retrieve the server group + * @return the name of the server group that the player is connected to, + * or an empty string if the player is not in a group server + */ + @NotNull + public String getServerGroup(@NotNull Player player) { + return getUser(player).map(t -> t.getServerGroup(plugin)).orElse(""); + } + static final class NotRegisteredException extends IllegalStateException { diff --git a/src/main/java/net/william278/velocitab/tab/PlayerTabList.java b/src/main/java/net/william278/velocitab/tab/PlayerTabList.java index b8ad74f..df72180 100644 --- a/src/main/java/net/william278/velocitab/tab/PlayerTabList.java +++ b/src/main/java/net/william278/velocitab/tab/PlayerTabList.java @@ -444,6 +444,8 @@ public class PlayerTabList { if (!p.getPlayer().getTabList().containsEntry(uuid)) { p.getPlayer().getTabList().addEntry(createEntry(tabPlayer, p.getPlayer().getTabList(), c)); + } else { + p.getPlayer().getTabList().getEntry(uuid).ifPresent(entry -> entry.setDisplayName(c)); } }));