mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-19 09:05:43 +01:00
7263cbca77
A recent commit has been made that caused patches to be out of order, rebuilding
56 lines
3.0 KiB
Diff
56 lines
3.0 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/AdvancementDataPlayer.java b/src/main/java/net/minecraft/server/AdvancementDataPlayer.java
|
|
index 17789407b9e86896a963a305a13357286aa5f319..c680319e4040be2b60795b22a5e65d6444cc67ed 100644
|
|
--- a/src/main/java/net/minecraft/server/AdvancementDataPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/AdvancementDataPlayer.java
|
|
@@ -78,6 +78,7 @@ public class AdvancementDataPlayer {
|
|
|
|
}
|
|
|
|
+ public final void reload(AdvancementDataWorld advancementDataWorld) { this.a(advancementDataWorld); } // Paper - OBFHELPER
|
|
public void a(AdvancementDataWorld advancementdataworld) {
|
|
this.a();
|
|
this.data.clear();
|
|
@@ -374,6 +375,7 @@ public class AdvancementDataPlayer {
|
|
|
|
}
|
|
|
|
+ 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
|
|
index ed926fc6ebbabd50a73d216a9e018a9427f5b128..0f7f1503d07bdff7ce7644dfe21e444adb52c7db 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
|
@@ -282,7 +282,13 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
|
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;
|
|
}
|