Paper/patches/api/0091-getPlayerUniqueId-API.patch
2021-06-21 09:57:15 -07:00

59 lines
2.3 KiB
Diff

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 c9f00ffe05c8624619b23ad22cf61233cede440e..1f4532e60abe62b88472a9bb0ef8d1af1f921220 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -504,6 +504,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 f2448c6dc8ef64393127a13c33eb14b0d5cd92c0..ca4e2d3b27f629e0d5e672fc915a5d03f0c0581d 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -429,6 +429,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.
*