mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 15:47:44 +01:00
35 lines
2 KiB
Diff
35 lines
2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jason Penilla <11360596+jpenilla@users.noreply.github.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/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
index 26e6fab362db3f5880bb5daddd4795465e969c27..1caee283ae73943f936eddd822fbe64dc7815fdf 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
@@ -345,7 +345,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().flushDirty(player);
|
|
+ });
|
|
+ // Paper end
|
|
|
|
return bukkit;
|
|
}
|