2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Thu, 22 Mar 2018 01:40:24 -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/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2023-06-13 01:51:45 +02:00
|
|
|
index 40090372a983b7064530e982a8ee1a9bc4913dfd..23407ccc0482f67db46947cbcc56c5488c42cf93 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2023-06-13 01:51:45 +02:00
|
|
|
@@ -1743,6 +1743,25 @@ public final class CraftServer implements Server {
|
2021-06-11 14:02:28 +02:00
|
|
|
return recipients.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ @Nullable
|
|
|
|
+ public UUID getPlayerUniqueId(String name) {
|
|
|
|
+ Player player = Bukkit.getPlayerExact(name);
|
|
|
|
+ if (player != null) {
|
|
|
|
+ return player.getUniqueId();
|
|
|
|
+ }
|
|
|
|
+ GameProfile profile;
|
|
|
|
+ // Only fetch an online UUID in online mode
|
2022-06-09 10:51:45 +02:00
|
|
|
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode()) {
|
2021-07-07 08:52:40 +02:00
|
|
|
+ profile = console.getProfileCache().get(name).orElse(null);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ } else {
|
|
|
|
+ // Make an OfflinePlayer using an offline mode UUID since the name has no profile
|
|
|
|
+ profile = new GameProfile(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)), name);
|
|
|
|
+ }
|
|
|
|
+ return profile != null ? profile.getId() : null;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
@Deprecated
|
|
|
|
public OfflinePlayer getOfflinePlayer(String name) {
|