PaperMC/patches/api/0093-getPlayerUniqueId-API.patch
Nassim Jahnke 8e8d6aeeb0 Finish API
2023-12-05 18:33:18 +01:00

58 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 8c430623204d419a93ccc67a0214942952f4a33c..9f52c092d906622e2eade3bc9d8baac6816f9f3a 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -689,6 +689,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 405b6a388c3593a83985f766e79b92951006563e..aace34252f65dd54868b521288f68c641b7ed71e 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -593,6 +593,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.
*