2021-06-11 14:02:28 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2021-06-17 11:37:24 +02:00
|
|
|
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
2021-06-11 14:02:28 +02:00
|
|
|
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/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
2024-10-24 19:29:35 +02:00
|
|
|
index 249c0f717a80b9ca8e200ebdbf72a0dc4c3730cc..6e8351363af9aea752286311074d53f245196e8d 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
2024-10-21 00:06:54 +02:00
|
|
|
@@ -323,7 +323,13 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
2021-06-11 14:02:28 +02:00
|
|
|
Bukkit.getLogger().log(Level.SEVERE, "Error saving advancement " + key, ex);
|
|
|
|
}
|
|
|
|
|
|
|
|
- MinecraftServer.getServer().getPlayerList().reloadResources();
|
2024-01-20 12:50:16 +01:00
|
|
|
+ // Paper start - Fix client lag on advancement loading
|
2021-06-11 14:02:28 +02:00
|
|
|
+ //MinecraftServer.getServer().getPlayerList().reload();
|
|
|
|
+ MinecraftServer.getServer().getPlayerList().getPlayers().forEach(player -> {
|
|
|
|
+ player.getAdvancements().reload(MinecraftServer.getServer().getAdvancements());
|
2021-06-17 19:11:00 +02:00
|
|
|
+ player.getAdvancements().flushDirty(player);
|
2021-06-11 14:02:28 +02:00
|
|
|
+ });
|
2024-01-20 12:50:16 +01:00
|
|
|
+ // Paper end - Fix client lag on advancement loading
|
2021-06-11 14:02:28 +02:00
|
|
|
|
|
|
|
return bukkit;
|
|
|
|
}
|