Paper/Spigot-API-Patches/0088-getPlayerUniqueId-API.patch

59 lines
2.3 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 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 c7019397923f9f9349bb5fdd15455f2dbf99bfd5..9ea3d8695dbfbfffb02919531a86b713cade7bec 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -498,6 +498,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 66d0a3c6de2ea3c0a2fe3cd160a52f0cabe58ef3..89deb6890e008832df06c4b6392ffb32d88a9c2d 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -423,6 +423,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.
*