From b9ab5132c325eab01ca49eabf7227fff869afdbb Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Wed, 5 May 2021 03:54:42 +0100 Subject: [PATCH] fix isProxyOnlineMode coverage, don't lookup UUIDs in offline mode (Fixes #2011) --- ...setting-for-proxy-online-mode-status.patch | 21 +++++++++++++++++++ .../Basic-PlayerProfile-API.patch | 6 +++--- .../getPlayerUniqueId-API.patch | 3 +-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Spigot-Server-Patches/Add-setting-for-proxy-online-mode-status.patch b/Spigot-Server-Patches/Add-setting-for-proxy-online-mode-status.patch index 339e8c01aa..f7766069ab 100644 --- a/Spigot-Server-Patches/Add-setting-for-proxy-online-mode-status.patch +++ b/Spigot-Server-Patches/Add-setting-for-proxy-online-mode-status.patch @@ -44,6 +44,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 minecraftserver.getGameProfileRepository().findProfilesByNames(astring, Agent.MINECRAFT, profilelookupcallback); } else { String[] astring1 = astring; +diff --git a/src/main/java/net/minecraft/server/players/UserCache.java b/src/main/java/net/minecraft/server/players/UserCache.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/players/UserCache.java ++++ b/src/main/java/net/minecraft/server/players/UserCache.java +@@ -0,0 +0,0 @@ public class UserCache { + } + }; + ++ if (com.destroystokyo.paper.PaperConfig.isProxyOnlineMode()) // Paper - only run in online mode - 100 COL + gameprofilerepository.findProfilesByNames(new String[]{s}, Agent.MINECRAFT, profilelookupcallback); + GameProfile gameprofile = (GameProfile) atomicreference.get(); + +@@ -0,0 +0,0 @@ public class UserCache { + } + + private static boolean c() { +- return UserCache.b; ++ return com.destroystokyo.paper.PaperConfig.isProxyOnlineMode(); // Paper + } + + public synchronized void a(GameProfile gameprofile) { // Paper - synchronize diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java diff --git a/Spigot-Server-Patches/Basic-PlayerProfile-API.patch b/Spigot-Server-Patches/Basic-PlayerProfile-API.patch index 86524f0681..f1242a28df 100644 --- a/Spigot-Server-Patches/Basic-PlayerProfile-API.patch +++ b/Spigot-Server-Patches/Basic-PlayerProfile-API.patch @@ -150,7 +150,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override + public boolean completeFromCache() { + MinecraftServer server = MinecraftServer.getServer(); -+ return completeFromCache(false, server.getOnlineMode() || (SpigotConfig.bungee && PaperConfig.bungeeOnlineMode)); ++ return completeFromCache(false, PaperConfig.isProxyOnlineMode()); + } + + public boolean completeFromCache(boolean onlineMode) { @@ -193,7 +193,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + public boolean complete(boolean textures) { + MinecraftServer server = MinecraftServer.getServer(); -+ return complete(textures, server.getOnlineMode() || (SpigotConfig.bungee && PaperConfig.bungeeOnlineMode)); ++ return complete(textures, PaperConfig.isProxyOnlineMode()); + } + public boolean complete(boolean textures, boolean onlineMode) { + MinecraftServer server = MinecraftServer.getServer(); @@ -486,7 +486,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private final GameProfileRepository e; private final Gson f = (new GsonBuilder()).create(); @@ -0,0 +0,0 @@ public class UserCache { - return UserCache.b; + return com.destroystokyo.paper.PaperConfig.isProxyOnlineMode(); // Paper } + public void saveProfile(GameProfile gameprofile) { a(gameprofile); } // Paper - OBFHELPER diff --git a/Spigot-Server-Patches/getPlayerUniqueId-API.patch b/Spigot-Server-Patches/getPlayerUniqueId-API.patch index 926d65cc33..909c39c32f 100644 --- a/Spigot-Server-Patches/getPlayerUniqueId-API.patch +++ b/Spigot-Server-Patches/getPlayerUniqueId-API.patch @@ -25,8 +25,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + GameProfile profile; + // Only fetch an online UUID in online mode -+ if (net.minecraft.server.MinecraftServer.getServer().getOnlineMode() -+ || (org.spigotmc.SpigotConfig.bungee && com.destroystokyo.paper.PaperConfig.bungeeOnlineMode)) { ++ if (com.destroystokyo.paper.PaperConfig.isProxyOnlineMode()) { + profile = console.getUserCache().getProfile( name ); + } else { + // Make an OfflinePlayer using an offline mode UUID since the name has no profile