diff --git a/api/src/main/java/com/velocitypowered/api/proxy/player/TabList.java b/api/src/main/java/com/velocitypowered/api/proxy/player/TabList.java index bae82a6ef..bceed260f 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/player/TabList.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/player/TabList.java @@ -61,6 +61,15 @@ public interface TabList { */ boolean containsEntry(UUID uuid); + /** + * Retrieves the tab list entry associated with the given uuid. + * + * @param uuid The player's {@link UUID} the {@link TabListEntry} is in reference to. + * @return {@code Optional.empty()} if the player is not present in the provided player's + * {@link TabList} otherwise a present {@link TabListEntry} in relation to the player. + */ + Optional getEntry(UUID uuid); + /** * Returns an immutable {@link Collection} of the {@link TabListEntry}s in the tab list. * diff --git a/proxy/src/main/java/com/velocitypowered/proxy/tablist/KeyedVelocityTabList.java b/proxy/src/main/java/com/velocitypowered/proxy/tablist/KeyedVelocityTabList.java index 74055fd3e..63a9ae56f 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/tablist/KeyedVelocityTabList.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/tablist/KeyedVelocityTabList.java @@ -111,6 +111,11 @@ public class KeyedVelocityTabList implements InternalTabList { return entries.containsKey(uuid); } + @Override + public Optional getEntry(UUID uuid) { + return Optional.ofNullable(this.entries.get(uuid)); + } + /** * Clears all entries from the tab list. Note that the entries are written with * {@link MinecraftConnection#delayedWrite(Object)}, so make sure to do an explicit diff --git a/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabList.java b/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabList.java index c183e7227..f707c95ca 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabList.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/tablist/VelocityTabList.java @@ -162,6 +162,11 @@ public class VelocityTabList implements InternalTabList { return this.entries.containsKey(uuid); } + @Override + public Optional getEntry(UUID uuid) { + return Optional.ofNullable(this.entries.get(uuid)); + } + @Override public Collection getEntries() { return this.entries.values().stream().map(e -> (TabListEntry) e).collect(Collectors.toList());