mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 19:52:55 +01:00
a207d14a0e
Signed-off-by: Mariell Hoversholm <proximyst@proximyst.com>
55 lines
3 KiB
Diff
55 lines
3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: jmp <jasonpenilla2@me.com>
|
|
Date: Sat, 31 Oct 2020 11:49:01 -0700
|
|
Subject: [PATCH] Fix client lag on advancement loading
|
|
|
|
When new advancements are added via the UnsafeValues#loadAdvancement
|
|
API, it triggers a full datapack reload when this is not necessary. The
|
|
advancement is already loaded directly into the advancement registry,
|
|
and the point of saving the advancement to the Bukkit datapack seems to
|
|
be for persistence. By removing the call to reload datapacks when an
|
|
advancement is loaded, the client no longer completely freezes up when
|
|
adding a new advancement.
|
|
To ensure the client still receives the updated advancement data, we
|
|
manually reload the advancement data for all players, which
|
|
normally takes place as a part of the datapack reloading.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerAdvancements.java b/src/main/java/net/minecraft/server/PlayerAdvancements.java
|
|
index acb41cc3965154c5b515cd8e808bf2cf5dc850e4..b8d3f2c59199e245e2035d6205dd1a042aa93f77 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerAdvancements.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java
|
|
@@ -97,6 +97,7 @@ public class PlayerAdvancements {
|
|
|
|
}
|
|
|
|
+ public final void reload(ServerAdvancementManager advancementDataWorld) { this.reload(advancementDataWorld); } // Paper - OBFHELPER
|
|
public void reload(ServerAdvancementManager advancementLoader) {
|
|
this.stopListening();
|
|
this.advancements.clear();
|
|
@@ -393,6 +394,7 @@ public class PlayerAdvancements {
|
|
|
|
}
|
|
|
|
+ public final void sendUpdateIfNeeded(ServerPlayer entityPlayer) { this.flushDirty(entityPlayer); } // Paper - OBFHELPER
|
|
public void flushDirty(ServerPlayer player) {
|
|
if (this.isFirstPacket || !this.visibilityChanged.isEmpty() || !this.progressChanged.isEmpty()) {
|
|
Map<ResourceLocation, AdvancementProgress> map = Maps.newHashMap();
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
index 9a16882deee21faf78ea46e08b2f2ad3fbb6021b..ac94fd569bd4c79e30adef148e09e395ba8c1812 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
@@ -307,7 +307,13 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
|
Bukkit.getLogger().log(Level.SEVERE, "Error saving advancement " + key, ex);
|
|
}
|
|
|
|
- MinecraftServer.getServer().getPlayerList().reloadResources();
|
|
+ // Paper start
|
|
+ //MinecraftServer.getServer().getPlayerList().reload();
|
|
+ MinecraftServer.getServer().getPlayerList().getPlayers().forEach(player -> {
|
|
+ player.getAdvancements().reload(MinecraftServer.getServer().getAdvancements());
|
|
+ player.getAdvancements().sendUpdateIfNeeded(player);
|
|
+ });
|
|
+ // Paper end
|
|
|
|
return bukkit;
|
|
}
|