fix isProxyOnlineMode coverage, don't lookup UUIDs in offline mode (Fixes #2011)

This commit is contained in:
Shane Freeder 2021-05-05 03:54:42 +01:00
parent 81cc4f9280
commit 453e983e4b
No known key found for this signature in database
GPG Key ID: A3F61EA5A085289C
14 changed files with 54 additions and 34 deletions

View File

@ -44,6 +44,27 @@ index 8a343a857dc4661ba256e39cf391dd2c7a1cc970..8c1f328ca1ba12ed63ec7bd7efad54ff
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 4ad084e7cea3b341ca0dbaa6e853cfc685a555ff..b9f94f957dd5372c8b02d785204690e4ade36a98 100644
--- a/src/main/java/net/minecraft/server/players/UserCache.java
+++ b/src/main/java/net/minecraft/server/players/UserCache.java
@@ -89,6 +89,7 @@ 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();
@@ -106,7 +107,7 @@ 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 96abe76ab9d71561740499b4dfcfa94ded1c1b53..f1572f708911d61ae6dc0077475fee8d815e28db 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java

View File

@ -7,7 +7,7 @@ Establishes base extension of profile systems for future edits too
diff --git a/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java
new file mode 100644
index 0000000000000000000000000000000000000000..040fd0c3fc4bc3a04fe5dff919a41fe9b474708e
index 0000000000000000000000000000000000000000..3d9452892a4077e64f37424052a9e52d76dd7a6d
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java
@@ -0,0 +1,301 @@
@ -150,7 +150,7 @@ index 0000000000000000000000000000000000000000..040fd0c3fc4bc3a04fe5dff919a41fe9
+ @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..040fd0c3fc4bc3a04fe5dff919a41fe9
+
+ 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();
@ -473,7 +473,7 @@ index 89db31061fcc3420bc8e668533a4051cdbd12253..191a74bd9b894f9d64d0a55747cb17e0
GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository();
UserCache usercache = new UserCache(gameprofilerepository, new File(file, MinecraftServer.b.getName()));
diff --git a/src/main/java/net/minecraft/server/players/UserCache.java b/src/main/java/net/minecraft/server/players/UserCache.java
index 4ad084e7cea3b341ca0dbaa6e853cfc685a555ff..e17927ecc3ad3e27e436082ac94e3772d7311725 100644
index b9f94f957dd5372c8b02d785204690e4ade36a98..692d95c94df85d752a3ddc66e1f2af765565b160 100644
--- a/src/main/java/net/minecraft/server/players/UserCache.java
+++ b/src/main/java/net/minecraft/server/players/UserCache.java
@@ -45,7 +45,7 @@ public class UserCache {
@ -485,15 +485,15 @@ index 4ad084e7cea3b341ca0dbaa6e853cfc685a555ff..e17927ecc3ad3e27e436082ac94e3772
private final Map<UUID, UserCache.UserCacheEntry> d = Maps.newConcurrentMap();
private final GameProfileRepository e;
private final Gson f = (new GsonBuilder()).create();
@@ -109,6 +109,7 @@ public class UserCache {
return UserCache.b;
@@ -110,6 +110,7 @@ public class UserCache {
return com.destroystokyo.paper.PaperConfig.isProxyOnlineMode(); // Paper
}
+ public void saveProfile(GameProfile gameprofile) { a(gameprofile); } // Paper - OBFHELPER
public synchronized void a(GameProfile gameprofile) { // Paper - synchronize
Calendar calendar = Calendar.getInstance();
@@ -158,6 +159,13 @@ public class UserCache {
@@ -159,6 +160,13 @@ public class UserCache {
return gameprofile;
}
@ -507,7 +507,7 @@ index 4ad084e7cea3b341ca0dbaa6e853cfc685a555ff..e17927ecc3ad3e27e436082ac94e3772
@Nullable
public GameProfile getProfile(UUID uuid) {
UserCache.UserCacheEntry usercache_usercacheentry = (UserCache.UserCacheEntry) this.d.get(uuid);
@@ -340,7 +348,7 @@ public class UserCache {
@@ -341,7 +349,7 @@ public class UserCache {
static class UserCacheEntry {

View File

@ -9,10 +9,10 @@ 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 cef40ca8f3c7da1ac16dc11c3643899f2fe45098..ece800d6f7d156be97e3069f76df5d667b9ce94d 100644
index f1d4e2ac2823e2246463350b21f28c6d32f4f2c5..6b0b55aa2ac4dec4e6005f557b9ba6975a7b58ed 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1511,6 +1511,26 @@ public final class CraftServer implements Server {
@@ -1511,6 +1511,25 @@ public final class CraftServer implements Server {
return recipients.size();
}
@ -25,8 +25,7 @@ index cef40ca8f3c7da1ac16dc11c3643899f2fe45098..ece800d6f7d156be97e3069f76df5d66
+ }
+ 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

View File

@ -29,10 +29,10 @@ index 13edb435b3fa65b4980bd7472aa5a5196f4d5b2b..469f78775b03cf363d88e35c69c0dc18
Object val = config.get("settings.save-player-data");
if (val instanceof Boolean) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index ed541a9782d09d3537e04e3651833208a83d7b12..0b16f2b3dad8f391a4067cbac99a8d01acbaacb4 100644
index 8f472f34e4839c1c6b02b2464d73635085a78544..c1e563b76271ad84654fe2abf31f86815600dca6 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2335,6 +2335,11 @@ public final class CraftServer implements Server {
@@ -2334,6 +2334,11 @@ public final class CraftServer implements Server {
return com.destroystokyo.paper.PaperConfig.suggestPlayersWhenNullTabCompletions;
}

View File

@ -29,10 +29,10 @@ index 602deb6b456de6cdefc480bf1aab959f9d60007d..5020b1ef1e0fc08a00a40aecfd3eeb74
public boolean isDebugging() {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 0b16f2b3dad8f391a4067cbac99a8d01acbaacb4..153de70249442caa3568fb2591cfd88bdb37e687 100644
index c1e563b76271ad84654fe2abf31f86815600dca6..841443e8dc9e72296d364fa61f8778d7c24038c9 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1834,7 +1834,7 @@ public final class CraftServer implements Server {
@@ -1833,7 +1833,7 @@ public final class CraftServer implements Server {
@Override
public boolean isPrimaryThread() {

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Expose the internal current tick
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 153de70249442caa3568fb2591cfd88bdb37e687..cfacac7233c6e1f1a34aee1b5d26a072949fd512 100644
index 841443e8dc9e72296d364fa61f8778d7c24038c9..6a92b46d127d6c3b30123343c3c0e2926174a7f8 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2358,5 +2358,10 @@ public final class CraftServer implements Server {
@@ -2357,5 +2357,10 @@ public final class CraftServer implements Server {
}
return new com.destroystokyo.paper.profile.CraftPlayerProfile(uuid, name);
}

View File

@ -147,10 +147,10 @@ index 18d078f85acf33e55e77758746f789af8f8d8076..7ae852296900b0f2ca53311e6884f01e
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index cfacac7233c6e1f1a34aee1b5d26a072949fd512..f8e053a1c128b345051d00307997eb2bea79a98d 100644
index 6a92b46d127d6c3b30123343c3c0e2926174a7f8..a42650f6353b86a5054d071a4355c6d3b5dc926e 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2196,6 +2196,16 @@ public final class CraftServer implements Server {
@@ -2195,6 +2195,16 @@ public final class CraftServer implements Server {
net.minecraft.server.MinecraftServer.getServer().tps15.getAverage()
};
}

View File

@ -6,10 +6,10 @@ Subject: [PATCH] Expose MinecraftServer#isRunning
This allows for plugins to detect if the server is actually turning off in onDisable rather than just plugins reloading.
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index f8e053a1c128b345051d00307997eb2bea79a98d..4828d356ca01cba5964c6397584d56643dbc0dae 100644
index a42650f6353b86a5054d071a4355c6d3b5dc926e..35d3d3d49fb5231df7ec7820c6c422abfb8165a5 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2373,5 +2373,10 @@ public final class CraftServer implements Server {
@@ -2372,5 +2372,10 @@ public final class CraftServer implements Server {
public int getCurrentTick() {
return net.minecraft.server.MinecraftServer.currentTick;
}

View File

@ -345,10 +345,10 @@ index cc41dcd85760b57bb8076b37e9a907d1cb4e12c7..efcfc8f0f45901d14ac8fdf8ed7b0bd6
String msg = "Entity threw exception at " + entity.world.getWorld().getName() + ":" + entity.locX() + "," + entity.locY() + "," + entity.locZ();
System.err.println(msg);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 4828d356ca01cba5964c6397584d56643dbc0dae..55890ff463eb122934e8ba1fc550cf0cccaf8451 100644
index 35d3d3d49fb5231df7ec7820c6c422abfb8165a5..4373cd10711a6250745d93da697e4e11818be8e6 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1834,7 +1834,7 @@ public final class CraftServer implements Server {
@@ -1833,7 +1833,7 @@ public final class CraftServer implements Server {
@Override
public boolean isPrimaryThread() {

View File

@ -1043,10 +1043,10 @@ index 8c8e39d35fb56aa6cf7d456adab01dff5d13a60d..bcf6c924894f49f1c602b83b501f904e
public PathfinderGoalWrapped(int i, PathfinderGoal pathfindergoal) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 96652862531301c08aefa0baa79b1258b5b307ec..3014a5d71de98009bdc121ba690c3653c2eef120 100644
index 352f4caec33de8a4351392859b43caa6b02d51c4..e20e3d69ac1c4cf97afd522340464e53d2497c08 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2385,5 +2385,11 @@ public final class CraftServer implements Server {
@@ -2384,5 +2384,11 @@ public final class CraftServer implements Server {
public boolean isStopping() {
return net.minecraft.server.MinecraftServer.getServer().hasStopped();
}

View File

@ -27,10 +27,10 @@ index 60ecd3a92af0f1968b10bb8babfb43147ef568d3..9077b70650d70dd294f53a1ef73e86e2
for (int l = 0; l < k; ++l) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index d0c951878600a4227e558bc68d68098c59fb7b2b..f8d040ba6c8b3a1294a8ac8d55cbd09705d4be76 100644
index e95093e1b2d7368a796e3e98e2bd491906164e44..d0eb0509953ddcd8d25bf3a9fd4f2170f7b88037 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2027,6 +2027,32 @@ public final class CraftServer implements Server {
@@ -2026,6 +2026,32 @@ public final class CraftServer implements Server {
return new CraftChunkData(world);
}

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Add getOfflinePlayerIfCached(String)
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 1199644c6342379df21840aa144e731e9e9245ca..fe2ad3f9298af4d405711b4798e34ae484a19db9 100644
index 21bc20882835243bff5308e6a6a168e9811f5a60..38553aa11224a1621e7a06801a0448a0948ce130 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1607,6 +1607,28 @@ public final class CraftServer implements Server {
@@ -1606,6 +1606,28 @@ public final class CraftServer implements Server {
return result;
}

View File

@ -40,10 +40,10 @@ index 0000000000000000000000000000000000000000..2ca8e1bade5450a14125b77540792e0b
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index fe2ad3f9298af4d405711b4798e34ae484a19db9..a4755e2cdb40afe6af47435f92963a53d7b719c7 100644
index 38553aa11224a1621e7a06801a0448a0948ce130..bc8cb33d2d41deeeecc7b8740ef49d7f79076fcc 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2216,6 +2216,11 @@ public final class CraftServer implements Server {
@@ -2215,6 +2215,11 @@ public final class CraftServer implements Server {
Preconditions.checkArgument(clazz == org.bukkit.Fluid.class, "Fluid namespace must have fluid type");
return (org.bukkit.Tag<T>) new CraftFluidTag(console.getTagRegistry().getFluidTags(), key);

View File

@ -61,10 +61,10 @@ index 24b3a893a2b76a4ecfbc6b2cc1eac242e5c6e9d6..92ed4938d5fe6b76e3a9ac5491d6e9c0
public void a(NetworkManager networkmanager, EntityPlayer entityplayer) {
EntityPlayer prev = pendingPlayers.put(entityplayer.getUniqueID(), entityplayer);// Paper
diff --git a/src/main/java/net/minecraft/server/players/UserCache.java b/src/main/java/net/minecraft/server/players/UserCache.java
index e17927ecc3ad3e27e436082ac94e3772d7311725..e813d4dd1a46734d16b42905808caa889811afcc 100644
index 692d95c94df85d752a3ddc66e1f2af765565b160..c617b7dd5a992770fc87113987807947ae68be81 100644
--- a/src/main/java/net/minecraft/server/players/UserCache.java
+++ b/src/main/java/net/minecraft/server/players/UserCache.java
@@ -242,6 +242,7 @@ public class UserCache {
@@ -243,6 +243,7 @@ public class UserCache {
return arraylist;
}