From 5e827822832099c2daaeb1ef1dadb6a6fc4797b5 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sun, 31 Dec 2023 10:46:30 +1100 Subject: [PATCH] Only fetch an online UUID in online mode The previous code would get an online UUID even in offline mode that breaks plugins if the player joins. Example: You want to store data for player "Test" who never joined. An online UUID is created and you save it using that UUID. The player Test joins with an offline UUID but that will not match the online UUID of the saved data. Adapted from Spigot commit 25b673fd7e418e21eb445a9e39d51baa0c0ab8b6 By: Maxim Van de Wynckel --- .../main/java/org/bukkit/craftbukkit/CraftServer.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 6b8f4c6200..9cb58095c4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1746,8 +1746,13 @@ public final class CraftServer implements Server { OfflinePlayer result = getPlayerExact(name); if (result == null) { - // This is potentially blocking :( - GameProfile profile = console.getProfileCache().get(name).orElse(null); + GameProfile profile = null; + // Only fetch an online UUID in online mode + if (getOnlineMode()) { + // This is potentially blocking :( + profile = console.getProfileCache().get(name).orElse(null); + } + if (profile == null) { // Make an OfflinePlayer using an offline mode UUID since the name has no profile result = getOfflinePlayer(new GameProfile(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)), name));