From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Aikar Date: Thu, 22 Mar 2018 01:39:28 -0400 Subject: [PATCH] getPlayerUniqueId API Gets the unique ID of the player currently known as the specified player name In Offline Mode, will return an Offline UUID This is a more performant way to obtain a UUID for a name than loading an OfflinePlayer diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java index 11288c4e1cb6a1f8322c6cbacb3750e6b08dad5e..579b002425024a942091c95880366ba8f1761e1c 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java @@ -699,6 +699,20 @@ public final class Bukkit { return server.getPlayer(id); } + // Paper start + /** + * Gets the unique ID of the player currently known as the specified player name + * In Offline Mode, will return an Offline UUID + * + * @param playerName the player name to look up the unique ID for + * @return A UUID, or null if that player name is not registered with Minecraft and the server is in online mode + */ + @Nullable + public static UUID getPlayerUniqueId(@NotNull String playerName) { + return server.getPlayerUniqueId(playerName); + } + // Paper end + /** * Gets the plugin manager for interfacing with plugins. * diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java index 4d500904b28375f8517aa05075667da22f23f754..4c16d026c6850f38295e71f4f4299e81f3e4c856 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -601,6 +601,18 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi @Nullable public Player getPlayer(@NotNull UUID id); + // Paper start + /** + * Gets the unique ID of the player currently known as the specified player name + * In Offline Mode, will return an Offline UUID + * + * @param playerName the player name to look up the unique ID for + * @return A UUID, or null if that player name is not registered with Minecraft and the server is in online mode + */ + @Nullable + public UUID getPlayerUniqueId(@NotNull String playerName); + // Paper end + /** * Gets the plugin manager for interfacing with plugins. *