aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0188-Add-option-to-remove-invalid-statistics.patch
blob: 495c8852ec6a4c92a9a4e6ebf90a89aa17219b0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
From e9c26ebbca617b1eb4856800b106a7a708e8bffc 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 009bf0c8b..a901cd85c 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -261,4 +261,13 @@ public class PaperConfig {
     private static void playerAutoSaveRate() {
         playerAutoSaveRate = getInt("settings.player-auto-save-rate", -1);
     }
+
+    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 99466dbde..d1bee0257 100644
--- a/src/main/java/net/minecraft/server/ServerStatisticManager.java
+++ b/src/main/java/net/minecraft/server/ServerStatisticManager.java
@@ -104,6 +104,7 @@ public class ServerStatisticManager extends StatisticManager {
             JsonObject jsonobject = jsonelement.getAsJsonObject();
             HashMap hashmap = Maps.newHashMap();
             Iterator iterator = jsonobject.entrySet().iterator();
+            java.util.List<String> invalidStats = com.google.common.collect.Lists.newArrayList(); // Paper
 
             while (iterator.hasNext()) {
                 Entry entry = (Entry) iterator.next();
@@ -137,9 +138,17 @@ public class ServerStatisticManager extends StatisticManager {
                     hashmap.put(statistic, statisticwrapper);
                 } else {
                     ServerStatisticManager.b.warn("Invalid statistic in {}: Don\'t know what {} is", new Object[] { this.d, entry.getKey()});
+                    if (com.destroystokyo.paper.PaperConfig.removeInvalidStatistics) invalidStats.add((String) entry.getKey()); // Paper
                 }
             }
 
+            // Paper start - Remove invalid statistics
+            for (String invalid : invalidStats) {
+                jsonobject.remove(invalid);
+                ServerStatisticManager.b.info("Removing invalid statistic: " + invalid);
+            }
+            // Paper end
+
             return hashmap;
         }
     }
-- 
2.12.2