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 039c44654621c434a8cc1fa4a2dc46ede793054a..97ed7d9f6415219db4d6b0054dc3d2afeb1ce6e5 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java @@ -489,6 +489,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 5582e377bb2a85b94d0c9c2a90d5b488991af098..da9c85372605ab0d68f21bb38885eb0f4dfebded 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -416,6 +416,18 @@ public interface Server extends PluginMessageRecipient { @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. *