From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Martijn Muijsers Date: Thu, 24 Nov 2022 23:39:32 +0100 Subject: [PATCH] Do not log invalid statistics License: MIT (https://opensource.org/licenses/MIT) Gale - https://galemc.org This patch is based on the following patch: "Ignore statistics warnings" By: Aikar As part of: EmpireCraft (https://github.com/starlis/empirecraft) Licensed under: MIT (https://opensource.org/licenses/MIT) diff --git a/net/minecraft/stats/ServerStatsCounter.java b/net/minecraft/stats/ServerStatsCounter.java index 16e06085ed3c0f6a0b35c730b63b75824f44a905..195ff539c9cb4b2a0640555fc4b59df39e06c90d 100644 --- a/net/minecraft/stats/ServerStatsCounter.java +++ b/net/minecraft/stats/ServerStatsCounter.java @@ -108,7 +108,7 @@ public class ServerStatsCounter extends StatsCounter { try { JsonElement jsonElement = StrictJsonParser.parse(json); if (jsonElement.isJsonNull()) { - LOGGER.error("Unable to parse Stat data from {}", this.file); + if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.invalidStatistics) LOGGER.error("Unable to parse Stat data from {}", this.file); return; } @@ -117,11 +117,13 @@ public class ServerStatsCounter extends StatsCounter { this.stats .putAll( STATS_CODEC.parse(dynamic.get("stats").orElseEmptyMap()) - .resultOrPartial(string -> LOGGER.error("Failed to parse statistics for {}: {}", this.file, string)) + .resultOrPartial(string -> { + if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.invalidStatistics) LOGGER.error("Failed to parse statistics for {}: {}", this.file, string); // Gale - EMC - do not log invalid statistics + }) .orElse(Map.of()) ); } catch (JsonParseException var5) { - LOGGER.error("Unable to parse Stat data from {}", this.file, var5); + if (org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.invalidStatistics) LOGGER.error("Unable to parse Stat data from {}", this.file, var5); } }