Fix advancement saving before reloads (#8003)

This commit is contained in:
Jake Potrebic 2022-06-16 13:59:53 -07:00 committed by GitHub
parent 0c1643c02c
commit 0ae78d381a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 38 additions and 31 deletions

View File

@ -71,7 +71,7 @@ index 8cc4cb2163a93b9491550fe6d0f5d980fb216920..4dd14d73a37b32288a64fbd67ee22c43
cause = cause.getCause();
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index ce7b96819bf8d7e992c2aafd3013e8a9478e500d..e055824c5414e3b723fbc2ba41e01fda96b72901 100644
index ce7b96819bf8d7e992c2aafd3013e8a9478e500d..53320d5d9cadb8702f82d94bada32db4c1b32f26 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -281,7 +281,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@ -219,13 +219,20 @@ index ce7b96819bf8d7e992c2aafd3013e8a9478e500d..e055824c5414e3b723fbc2ba41e01fda
throw new RuntimeException("Error generating crash report", t);
}
// Spigot End
@@ -1915,7 +1969,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1915,7 +1969,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.packRepository.setSelected(dataPacks);
this.worldData.setDataPackConfig(MinecraftServer.getSelectedPacks(this.packRepository));
this.resources.managers.updateRegistryTags(this.registryAccess());
- this.getPlayerList().saveAll();
+ if (Thread.currentThread() != this.serverThread) return; // Paper
+ //this.getPlayerList().saveAll(); // Paper - we don't need to do this
+ // Paper start
+ if (Thread.currentThread() != this.serverThread) {
+ return;
+ }
+ // this.getPlayerList().saveAll(); // Paper - we don't need to save everything, just advancements
+ for (ServerPlayer player : this.getPlayerList().getPlayers()) {
+ player.getAdvancements().save();
+ }
+ // Paper end
this.getPlayerList().reloadResources();
this.functionManager.replaceLibrary(this.resources.managers.getFunctionLibrary());
this.structureTemplateManager.onResourceManagerReload(this.resources.resourceManager);

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Cache block data strings
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 54a155295ed2ee2386f180bf8f5d413984febe96..adb0389c5b38fce4bab47e4cc748cfd95de13e90 100644
index 9ce0c366b81ee8468cfcca1bd9fb8ed49ffea0ba..343eb9e6417f94bec66b4d9ef583e04d603755cd 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1997,6 +1997,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -2004,6 +2004,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.getPlayerList().reloadResources();
this.functionManager.replaceLibrary(this.resources.managers.getFunctionLibrary());
this.structureTemplateManager.onResourceManagerReload(this.resources.resourceManager);

View File

@ -6,10 +6,10 @@ Subject: [PATCH] Fix deop kicking non-whitelisted player when white list is
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index adb0389c5b38fce4bab47e4cc748cfd95de13e90..0060211b3d85c07b44be3d3a534dcb8e35547d78 100644
index 343eb9e6417f94bec66b4d9ef583e04d603755cd..31c37ba3593d70f2f71ed5e0679c6188e2179f47 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -2063,13 +2063,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -2070,13 +2070,14 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
if (this.isEnforceWhitelist()) {
PlayerList playerlist = source.getServer().getPlayerList();
UserWhiteList whitelist = playerlist.getWhiteList();

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Added ServerResourcesReloadedEvent
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 0060211b3d85c07b44be3d3a534dcb8e35547d78..8460437b9210c8ae73795c65596ec35b491b18df 100644
index 31c37ba3593d70f2f71ed5e0679c6188e2179f47..5dd7b6669a9afbc7f2d78a7eded7fbf91eadc2b9 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1966,7 +1966,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@ -27,9 +27,9 @@ index 0060211b3d85c07b44be3d3a534dcb8e35547d78..8460437b9210c8ae73795c65596ec35b
this.worldData.setDataPackConfig(MinecraftServer.getSelectedPacks(this.packRepository));
this.resources.managers.updateRegistryTags(this.registryAccess());
+ new io.papermc.paper.event.server.ServerResourcesReloadedEvent(cause).callEvent(); // Paper
if (Thread.currentThread() != this.serverThread) return; // Paper
//this.getPlayerList().saveAll(); // Paper - we don't need to do this
this.getPlayerList().reloadResources();
// Paper start
if (Thread.currentThread() != this.serverThread) {
return;
diff --git a/src/main/java/net/minecraft/server/commands/ReloadCommand.java b/src/main/java/net/minecraft/server/commands/ReloadCommand.java
index 1eb85de1d10829bfb4dbbfa01efd5656dee70090..19eacd1b1c3aca23f864a1867e004455312e82f7 100644
--- a/src/main/java/net/minecraft/server/commands/ReloadCommand.java

View File

@ -193,7 +193,7 @@ index 0000000000000000000000000000000000000000..6f39e343147803e15e7681c993b8797a
+public record RegistryKey<API extends Keyed, MINECRAFT>(Class<API> apiClass, ResourceKey<? extends Registry<MINECRAFT>> resourceKey) {
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 8460437b9210c8ae73795c65596ec35b491b18df..18f050a80f9928bae3c1a0288f152907090644b7 100644
index 5dd7b6669a9afbc7f2d78a7eded7fbf91eadc2b9..3d8917c3baa0c308fe85cafcd332bfbe9bffede9 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1998,6 +1998,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@ -202,8 +202,8 @@ index 8460437b9210c8ae73795c65596ec35b491b18df..18f050a80f9928bae3c1a0288f152907
this.resources.managers.updateRegistryTags(this.registryAccess());
+ io.papermc.paper.registry.PaperRegistry.clearCaches(); // Paper
new io.papermc.paper.event.server.ServerResourcesReloadedEvent(cause).callEvent(); // Paper
if (Thread.currentThread() != this.serverThread) return; // Paper
//this.getPlayerList().saveAll(); // Paper - we don't need to do this
// Paper start
if (Thread.currentThread() != this.serverThread) {
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 4192a6eff940bfe7823f100d4156f5c4d82d994c..e4855c7652b6904b402e38144664266d8f757f73 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java

View File

@ -5,10 +5,10 @@ Subject: [PATCH] forced whitelist: use configurable kick message
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 57924d8f2ddac1e7c0c151c4813a2a5ca17e58b8..ff2a9dbacffdb1e4b790aedd61b82c7adf0831aa 100644
index 67c2ad20d0c1d63dcd43d9570fbcb5b9a30f4ee1..f73f16ffc65467db8fa370beddffb7cae054a13c 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -2080,7 +2080,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -2087,7 +2087,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
if (!whitelist.isWhiteListed(entityplayer.getGameProfile()) && !this.getPlayerList().isOp(entityplayer.getGameProfile())) { // Paper - Fix kicking ops when whitelist is reloaded (MC-171420)

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Add PlayerKickEvent causes
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index e232039b939ea226348405836dece6e5ac926aa8..b1a0f0b1bed05fbea5d21157317d08dd92ec78f0 100644
index 4ad7c5377c67fd156353166145b1edd39e41cd02..d7a20955b145a23917364726045ce7a5c53c867b 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -2083,7 +2083,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -2090,7 +2090,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
if (!whitelist.isWhiteListed(entityplayer.getGameProfile()) && !this.getPlayerList().isOp(entityplayer.getGameProfile())) { // Paper - Fix kicking ops when whitelist is reloaded (MC-171420)

View File

@ -6,7 +6,7 @@ Subject: [PATCH] Execute chunk tasks mid-tick
This will help the server load chunks if tick times are high.
diff --git a/src/main/java/co/aikar/timings/MinecraftTimings.java b/src/main/java/co/aikar/timings/MinecraftTimings.java
index 3b717a6a1be16f780923e7ae3269462d3d082615..8563c66834b0b9e77bca42e4f916d82a9bfe66e2 100644
index 23e564b05ba438924180c91f9b19a60731eedd1b..5ec241d49ff5e3a161a39006f05823a5de847c5e 100644
--- a/src/main/java/co/aikar/timings/MinecraftTimings.java
+++ b/src/main/java/co/aikar/timings/MinecraftTimings.java
@@ -46,6 +46,8 @@ public final class MinecraftTimings {
@ -19,7 +19,7 @@ index 3b717a6a1be16f780923e7ae3269462d3d082615..8563c66834b0b9e77bca42e4f916d82a
private MinecraftTimings() {}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index b1a0f0b1bed05fbea5d21157317d08dd92ec78f0..6f078f69f4da1bd988f02156351c481b6da04b55 100644
index d7a20955b145a23917364726045ce7a5c53c867b..07d717295beb6fff7d8b3387b895e046bd7482c2 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1302,6 +1302,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@ -30,7 +30,7 @@ index b1a0f0b1bed05fbea5d21157317d08dd92ec78f0..6f078f69f4da1bd988f02156351c481b
return true;
} else {
if (this.haveTime()) {
@@ -2623,4 +2624,74 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -2630,4 +2631,74 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
}
// Paper end
@ -126,7 +126,7 @@ index 438406936633b9c67d21b26527c3d1654118c744..2de322ffc2eedae9efe39f9b771c447d
}
// Paper start - optimise chunk tick iteration
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 463d665ee708d741440331393e0b0a97fc981200..572e635739cf43ddb4b4e51df59d4c2612b77034 100644
index 5aa9c963d0d66c506f0abf821367d1b78f3bf58c..2c1b2521b995a926c85e58d21926d9a3b8743304 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -210,6 +210,7 @@ public class ServerLevel extends Level implements WorldGenLevel {

View File

@ -24,7 +24,7 @@ index 0000000000000000000000000000000000000000..6b0bed550763f34e18c9e92f9a47ec0c
+ }
+}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 0ab7cf2b3b3fcb76a0f2eea300da7a29c258cd48..05e8e1cc33c0c4509ec157608e73989b423647ad 100644
index 7bcfb1420e67f941df4dd39a3b94c02f03ee27fa..ecaa4d9ff28551b7039f3489f1884d3b664c8ce6 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -2021,6 +2021,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@ -33,8 +33,8 @@ index 0ab7cf2b3b3fcb76a0f2eea300da7a29c258cd48..05e8e1cc33c0c4509ec157608e73989b
io.papermc.paper.registry.PaperRegistry.clearCaches(); // Paper
+ net.minecraft.world.item.alchemy.PotionBrewing.reload(); // Paper
new io.papermc.paper.event.server.ServerResourcesReloadedEvent(cause).callEvent(); // Paper
if (Thread.currentThread() != this.serverThread) return; // Paper
//this.getPlayerList().saveAll(); // Paper - we don't need to do this
// Paper start
if (Thread.currentThread() != this.serverThread) {
diff --git a/src/main/java/net/minecraft/world/inventory/BrewingStandMenu.java b/src/main/java/net/minecraft/world/inventory/BrewingStandMenu.java
index a809e8a903f98fcbcea3184fac6dfd04adc735f9..13720c2df8ac37d020d4a785e48c45877edf74b9 100644
--- a/src/main/java/net/minecraft/world/inventory/BrewingStandMenu.java

View File

@ -7,7 +7,7 @@ Subject: [PATCH] Fix World#locateNearestStructure
impl needs to be changed to reflect that
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 05e8e1cc33c0c4509ec157608e73989b423647ad..1bc400cf245ba3110e8874a4f2837a91d0f70916 100644
index ecaa4d9ff28551b7039f3489f1884d3b664c8ce6..eee4badba71c7e568224b91893a0647f8d8ab6cc 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -2022,6 +2022,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@ -20,10 +20,10 @@ index 05e8e1cc33c0c4509ec157608e73989b423647ad..1bc400cf245ba3110e8874a4f2837a91
+ }
+ // Paper end
new io.papermc.paper.event.server.ServerResourcesReloadedEvent(cause).callEvent(); // Paper
if (Thread.currentThread() != this.serverThread) return; // Paper
//this.getPlayerList().saveAll(); // Paper - we don't need to do this
// Paper start
if (Thread.currentThread() != this.serverThread) {
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index bcfa1959c2ffd9ee31804c5a00a84133599cbbc4..cf3622930aab7ff62e293622ab1cd5ff97ee68f5 100644
index da1533ade2d51a6a978ba4334d07b07681421693..570711979720d85590c10573e4201e60244df4eb 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1887,7 +1887,16 @@ public class ServerLevel extends Level implements WorldGenLevel {
@ -45,7 +45,7 @@ index bcfa1959c2ffd9ee31804c5a00a84133599cbbc4..cf3622930aab7ff62e293622ab1cd5ff
return pair != null ? (BlockPos) pair.getFirst() : null;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index bc387765a9d96f3901dd2e1db751262b1fdd4829..6f09519695a7268e4749a6c36b463f5b33bb645f 100644
index 131f40a7defc87a01f6a554f7c7819d34e84fe1d..526f7b170270efe34dc43110e23c013f19665b9e 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -2059,10 +2059,22 @@ public class CraftWorld extends CraftRegionAccessor implements World {