Paper/Spigot-Server-Patches/0158-Add-option-to-remove-invalid-statistics.patch

48 lines
2.4 KiB
Diff
Raw Normal View History

From 6a8062188a480ab5bc541016f54b972193b12045 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Tue, 20 Dec 2016 23:09:21 -0600
Subject: [PATCH] Add option to remove invalid statistics
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index ae3d0f8f7..6b92ea437 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -280,4 +280,13 @@ public class PaperConfig {
maxPlayerAutoSavePerTick = (playerAutoSaveRate == -1 || playerAutoSaveRate > 100) ? 10 : 20;
}
}
+
+ public static boolean removeInvalidStatistics = false;
+ private static void removeInvalidStatistics() {
+ if (version < 12) {
+ boolean oldValue = getBoolean("remove-invalid-statistics", false);
+ set("settings.remove-invalid-statistics", oldValue);
+ }
+ removeInvalidStatistics = getBoolean("settings.remove-invalid-statistics", false);
+ }
}
diff --git a/src/main/java/net/minecraft/server/ServerStatisticManager.java b/src/main/java/net/minecraft/server/ServerStatisticManager.java
index 6405f98e0..42e2f3d22 100644
--- a/src/main/java/net/minecraft/server/ServerStatisticManager.java
+++ b/src/main/java/net/minecraft/server/ServerStatisticManager.java
2018-07-17 22:32:05 +02:00
@@ -83,6 +83,7 @@ public class ServerStatisticManager extends StatisticManager {
try {
JsonReader jsonreader = new JsonReader(new StringReader(s));
Throwable throwable = null;
+ java.util.List<String> invalidStats = com.google.common.collect.Lists.newArrayList(); // Paper
2018-07-17 22:32:05 +02:00
try {
jsonreader.setLenient(false);
@@ -120,6 +121,7 @@ public class ServerStatisticManager extends StatisticManager {
if (statistic == null) {
ServerStatisticManager.b.warn("Invalid statistic in {}: Don\'t know what {} is", this.d, s2);
2018-07-17 22:32:05 +02:00
+ if (com.destroystokyo.paper.PaperConfig.removeInvalidStatistics) invalidStats.add(s2); // Paper
} else {
this.a.put(statistic, nbttagcompound2.getInt(s2));
}
--
2.19.1