9
0
mirror of https://github.com/SparklyPower/SparklyPaper.git synced 2025-12-19 15:09:27 +00:00
Files
SparklyPaperMC/patches/server/0007-Skip-dirty-stats-copy-when-requesting-player-stats.patch
MrPowerGamerBR e371a3ef2a Update to 1.21.1
2024-08-19 15:58:08 -03:00

47 lines
2.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MrPowerGamerBR <git@mrpowergamerbr.com>
Date: Wed, 22 Nov 2023 14:40:36 -0300
Subject: [PATCH] Skip dirty stats copy when requesting player stats
There's literally only one getDirty call. Because the map was only retrieved once, we don't actually need to create a copy of the map just to iterate it, we can just access it directly and clear it manually after use.
diff --git a/src/main/java/net/minecraft/stats/ServerStatsCounter.java b/src/main/java/net/minecraft/stats/ServerStatsCounter.java
index fb7342f7a5008a283c3400c6313c637de8210dfa..1f9b3cacb276c144ecbef104e5d598b78dc0c025 100644
--- a/src/main/java/net/minecraft/stats/ServerStatsCounter.java
+++ b/src/main/java/net/minecraft/stats/ServerStatsCounter.java
@@ -90,12 +90,16 @@ public class ServerStatsCounter extends StatsCounter {
this.dirty.add(stat);
}
+ // SparklyPaper start - Skip dirty stats copy when requesting player stats
+ /*
private Set<Stat<?>> getDirty() {
Set<Stat<?>> set = Sets.newHashSet(this.dirty);
this.dirty.clear();
return set;
}
+ */
+ // SparklyPaper end
public void parseLocal(DataFixer dataFixer, String json) {
try {
@@ -243,7 +247,7 @@ public class ServerStatsCounter extends StatsCounter {
public void sendStats(ServerPlayer player) {
Object2IntMap<Stat<?>> object2intmap = new Object2IntOpenHashMap();
- Iterator iterator = this.getDirty().iterator();
+ Iterator iterator = this.dirty.iterator(); // SparklyPaper - Skip dirty stats copy when requesting player stats
while (iterator.hasNext()) {
Stat<?> statistic = (Stat) iterator.next();
@@ -251,6 +255,8 @@ public class ServerStatsCounter extends StatsCounter {
object2intmap.put(statistic, this.getValue(statistic));
}
+ this.dirty.clear(); // SparklyPaper - Skip dirty stats copy when requesting player stats
+
player.connection.send(new ClientboundAwardStatsPacket(object2intmap));
}
}