9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2026-01-06 15:51:31 +00:00

improve ServerStatsCounter compatibility

This commit is contained in:
hayanesuru
2025-06-08 15:55:48 +09:00
parent 0eeb6e719c
commit 47c1783afc
2 changed files with 15 additions and 7 deletions

View File

@@ -138,10 +138,10 @@ index 75fb49f1596f475278d12c8c7aea9ad4952b6056..52a0fa425a30caa2e592c0fdda44800d
}
diff --git a/net/minecraft/stats/ServerStatsCounter.java b/net/minecraft/stats/ServerStatsCounter.java
index b26dbe807e5cb0a42f6c06b933397902310e5616..35ad7f249cfb6f5c779136d96f3698ea4de1eb7c 100644
index b26dbe807e5cb0a42f6c06b933397902310e5616..a682ae890850a5e62acd54029f2a4eb1e69d200a 100644
--- a/net/minecraft/stats/ServerStatsCounter.java
+++ b/net/minecraft/stats/ServerStatsCounter.java
@@ -39,12 +39,23 @@ public class ServerStatsCounter extends StatsCounter {
@@ -39,12 +39,31 @@ public class ServerStatsCounter extends StatsCounter {
private final File file;
private final Set<Stat<?>> dirty = Sets.newHashSet();
@@ -150,7 +150,15 @@ index b26dbe807e5cb0a42f6c06b933397902310e5616..35ad7f249cfb6f5c779136d96f3698ea
+ private final java.util.UUID uuid;
+ @Deprecated(forRemoval = true)
public ServerStatsCounter(MinecraftServer server, File file) {
+ throw new UnsupportedOperationException();
+ this(server, file, "UNKNOWN", parseUUID(file));
+ }
+ private static java.util.UUID parseUUID(File file) {
+ try {
+ return java.util.UUID.fromString(org.apache.commons.io.FilenameUtils.getBaseName(file.toString()));
+ } catch (IllegalArgumentException e) {
+ LOGGER.error("failed parse uuid {}", file, e);
+ return net.minecraft.Util.NIL_UUID;
+ }
+ }
+ public ServerStatsCounter(MinecraftServer server, File file, String name, java.util.UUID uuid) {
+ this.name = name;
@@ -166,7 +174,7 @@ index b26dbe807e5cb0a42f6c06b933397902310e5616..35ad7f249cfb6f5c779136d96f3698ea
} catch (IOException var4) {
LOGGER.error("Couldn't read statistics file {}", file, var4);
} catch (JsonParseException var5) {
@@ -66,11 +77,37 @@ public class ServerStatsCounter extends StatsCounter {
@@ -66,11 +85,37 @@ public class ServerStatsCounter extends StatsCounter {
public void save() {
if (org.spigotmc.SpigotConfig.disableStatSaving) return; // Spigot

View File

@@ -6,10 +6,10 @@ Subject: [PATCH] SparklyPaper: Skip dirty stats copy when requesting player
diff --git a/net/minecraft/stats/ServerStatsCounter.java b/net/minecraft/stats/ServerStatsCounter.java
index 35ad7f249cfb6f5c779136d96f3698ea4de1eb7c..523dc12a8866a199eac1b2f418bf206f068ba80c 100644
index a682ae890850a5e62acd54029f2a4eb1e69d200a..cd2b99f82a56836a4f4e32cd6e02450f77fe9149 100644
--- a/net/minecraft/stats/ServerStatsCounter.java
+++ b/net/minecraft/stats/ServerStatsCounter.java
@@ -118,11 +118,15 @@ public class ServerStatsCounter extends StatsCounter {
@@ -126,11 +126,15 @@ public class ServerStatsCounter extends StatsCounter {
this.dirty.add(stat);
}
@@ -25,7 +25,7 @@ index 35ad7f249cfb6f5c779136d96f3698ea4de1eb7c..523dc12a8866a199eac1b2f418bf206f
public void parseLocal(DataFixer fixerUpper, String json) {
try {
@@ -231,10 +235,12 @@ public class ServerStatsCounter extends StatsCounter {
@@ -239,10 +243,12 @@ public class ServerStatsCounter extends StatsCounter {
public void sendStats(ServerPlayer player) {
Object2IntMap<Stat<?>> map = new Object2IntOpenHashMap<>();