aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0185-getPlayerUniqueId-API.patch
diff options
context:
space:
mode:
authorJake <[email protected]>2021-11-29 23:32:30 -0800
committerMiniDigger | Martin <[email protected]>2021-11-30 19:26:33 +0100
commitd8d7f523247bc84ecaedccf2bae29da4c18af4f2 (patch)
treeb1695d85949cde1da6d3d1562f494f1fc74d863f /patches/server/0185-getPlayerUniqueId-API.patch
parent5ff792342c3a80ac8044340ac1e44c763ed38f1d (diff)
downloadPaper-d8d7f523247bc84ecaedccf2bae29da4c18af4f2.tar.gz
Paper-d8d7f523247bc84ecaedccf2bae29da4c18af4f2.zip
another patch
Diffstat (limited to 'patches/server/0185-getPlayerUniqueId-API.patch')
-rw-r--r--patches/server/0185-getPlayerUniqueId-API.patch40
1 files changed, 40 insertions, 0 deletions
diff --git a/patches/server/0185-getPlayerUniqueId-API.patch b/patches/server/0185-getPlayerUniqueId-API.patch
new file mode 100644
index 0000000000..51bcc8969b
--- /dev/null
+++ b/patches/server/0185-getPlayerUniqueId-API.patch
@@ -0,0 +1,40 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Aikar <[email protected]>
+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
+index c0270955c05baea285676615a5a75c165e00ffed..294e90195cd0d00ca6d77136d886797cb39cfca5 100644
+--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
++++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+@@ -1713,6 +1713,25 @@ public final class CraftServer implements Server {
+ 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
++ if (com.destroystokyo.paper.PaperConfig.isProxyOnlineMode()) {
++ profile = console.getProfileCache().get(name).orElse(null);
++ } 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) {