From fe2520594d10674868df1d45e4242049596a40c7 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Thu, 16 Jun 2022 13:59:53 -0700 Subject: [PATCH] Fix advancement saving before reloads (#8003) --- patches/server/Add-PaperRegistry.patch | 4 ++-- .../server/Added-ServerResourcesReloadedEvent.patch | 6 +++--- patches/server/Custom-Potion-Mixes.patch | 4 ++-- patches/server/Fix-World-locateNearestStructure.patch | 4 ++-- patches/server/Improved-Watchdog-Support.patch | 11 +++++++++-- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/patches/server/Add-PaperRegistry.patch b/patches/server/Add-PaperRegistry.patch index f91b27d14d..2bf6f5d6db 100644 --- a/patches/server/Add-PaperRegistry.patch +++ b/patches/server/Add-PaperRegistry.patch @@ -202,8 +202,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java diff --git a/patches/server/Added-ServerResourcesReloadedEvent.patch b/patches/server/Added-ServerResourcesReloadedEvent.patch index bf001ec0de..4bc75d712a 100644 --- a/patches/server/Added-ServerResourcesReloadedEvent.patch +++ b/patches/server/Added-ServerResourcesReloadedEvent.patch @@ -27,9 +27,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/commands/ReloadCommand.java diff --git a/patches/server/Custom-Potion-Mixes.patch b/patches/server/Custom-Potion-Mixes.patch index 62fa94b4da..bc1a530cfc 100644 --- a/patches/server/Custom-Potion-Mixes.patch +++ b/patches/server/Custom-Potion-Mixes.patch @@ -33,8 +33,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/inventory/BrewingStandMenu.java diff --git a/patches/server/Fix-World-locateNearestStructure.patch b/patches/server/Fix-World-locateNearestStructure.patch index 8826630184..f221ad3dc5 100644 --- a/patches/server/Fix-World-locateNearestStructure.patch +++ b/patches/server/Fix-World-locateNearestStructure.patch @@ -20,8 +20,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java diff --git a/patches/server/Improved-Watchdog-Support.patch b/patches/server/Improved-Watchdog-Support.patch index 77475b577f..87a10c2b59 100644 --- a/patches/server/Improved-Watchdog-Support.patch +++ b/patches/server/Improved-Watchdog-Support.patch @@ -224,8 +224,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 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);