Paper/Spigot-API-Patches/0092-getPlayerUniqueId-API.patch
Aikar 980d53d156
Expand Explosions API
Add Entity as a Source capability, and add more API choices, and on Location.
2018-06-20 23:19:46 -04:00

62 lines
2.1 KiB
Diff

From 2f0d6d93d9cff195b35e945039d8d6fe4439c25a Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
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 690d9c07..682d2bbf 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -424,6 +424,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(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 f2ee6516..2912bdae 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -354,6 +354,18 @@ public interface Server extends PluginMessageRecipient {
*/
public Player getPlayer(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(String playerName);
+ // Paper end
+
/**
* Gets the plugin manager for interfacing with plugins.
*
--
2.17.1