2020-11-11 17:18:36 +01:00
|
|
|
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/AdvancementDataPlayer.java b/src/main/java/net/minecraft/server/AdvancementDataPlayer.java
|
2021-03-16 14:04:28 +01:00
|
|
|
index cc89bc1880a8c095942ba4e34c1bf4202e8dbedc..10da42010d8f3a6a7863d3b594ece33a5b130aa7 100644
|
2020-11-11 17:18:36 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/AdvancementDataPlayer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/AdvancementDataPlayer.java
|
2021-03-16 14:04:28 +01:00
|
|
|
@@ -97,6 +97,7 @@ public class AdvancementDataPlayer {
|
2020-11-11 17:18:36 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
+ public final void reload(AdvancementDataWorld advancementDataWorld) { this.a(advancementDataWorld); } // Paper - OBFHELPER
|
|
|
|
public void a(AdvancementDataWorld advancementdataworld) {
|
|
|
|
this.a();
|
|
|
|
this.data.clear();
|
2021-03-16 14:04:28 +01:00
|
|
|
@@ -393,6 +394,7 @@ public class AdvancementDataPlayer {
|
2020-11-11 17:18:36 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
+ public final void sendUpdateIfNeeded(EntityPlayer entityPlayer) { this.b(entityPlayer); } // Paper - OBFHELPER
|
|
|
|
public void b(EntityPlayer entityplayer) {
|
|
|
|
if (this.m || !this.i.isEmpty() || !this.j.isEmpty()) {
|
|
|
|
Map<MinecraftKey, 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
|
2021-03-16 08:19:45 +01:00
|
|
|
index 25af57d0ab191f6a29ae95cec764667e9c23bdd4..4b7ca6d2e13fad43a75a345608b739f47adba738 100644
|
2020-11-11 17:18:36 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
2021-03-09 02:11:17 +01:00
|
|
|
@@ -289,7 +289,13 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
2020-11-11 17:18:36 +01:00
|
|
|
Bukkit.getLogger().log(Level.SEVERE, "Error saving advancement " + key, ex);
|
|
|
|
}
|
|
|
|
|
|
|
|
- MinecraftServer.getServer().getPlayerList().reload();
|
|
|
|
+ // Paper start
|
|
|
|
+ //MinecraftServer.getServer().getPlayerList().reload();
|
|
|
|
+ MinecraftServer.getServer().getPlayerList().getPlayers().forEach(player -> {
|
|
|
|
+ player.getAdvancementData().reload(MinecraftServer.getServer().getAdvancementData());
|
|
|
|
+ player.getAdvancementData().sendUpdateIfNeeded(player);
|
|
|
|
+ });
|
|
|
|
+ // Paper end
|
|
|
|
|
|
|
|
return bukkit;
|
|
|
|
}
|