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/src/main/java/net/minecraft/stats/ServerStatsCounter.java b/src/main/java/net/minecraft/stats/ServerStatsCounter.java index 72946e324c575ef39f3939225b96b68f724da460..75e2a7d19a7056b73c1524902e44cca05b03d622 100644 --- a/src/main/java/net/minecraft/stats/ServerStatsCounter.java +++ b/src/main/java/net/minecraft/stats/ServerStatsCounter.java @@ -36,6 +36,7 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.util.datafix.DataFixTypes; import net.minecraft.world.entity.player.Player; import org.apache.commons.io.FileUtils; +import org.galemc.gale.configuration.GaleGlobalConfiguration; import org.slf4j.Logger; public class ServerStatsCounter extends StatsCounter { @@ -135,15 +136,15 @@ public class ServerStatsCounter extends StatsCounter { Util.ifElse(this.getStat(statisticwrapper, s2), (statistic) -> { this.stats.put(statistic, nbttagcompound2.getInt(s2)); }, () -> { - ServerStatsCounter.LOGGER.warn("Invalid statistic in {}: Don't know what {} is", this.file, s2); + if (GaleGlobalConfiguration.get().logToConsole.invalidStatistics) ServerStatsCounter.LOGGER.warn("Invalid statistic in {}: Don't know what {} is", this.file, s2); // Gale - EMC - do not log invalid statistics }); } else { - ServerStatsCounter.LOGGER.warn("Invalid statistic value in {}: Don't know what {} is for key {}", new Object[]{this.file, nbttagcompound2.get(s2), s2}); + if (GaleGlobalConfiguration.get().logToConsole.invalidStatistics) ServerStatsCounter.LOGGER.warn("Invalid statistic value in {}: Don't know what {} is for key {}", new Object[]{this.file, nbttagcompound2.get(s2), s2}); // Gale - EMC - do not log invalid statistics } } }, () -> { - ServerStatsCounter.LOGGER.warn("Invalid statistic type in {}: Don't know what {} is", this.file, s1); + if (GaleGlobalConfiguration.get().logToConsole.invalidStatistics) ServerStatsCounter.LOGGER.warn("Invalid statistic type in {}: Don't know what {} is", this.file, s1); // Gale - EMC - do not log invalid statistics }); } } diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java index 5021cc0b7a0f99ec53d565862add241428311dc3..6b528eab517aed9c00c75b4bf6e1a7b21194c343 100644 --- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java +++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java @@ -71,6 +71,7 @@ public class GaleGlobalConfiguration extends ConfigurationPart { // Gale end - Pufferfish - make chat order verification configurable public IncludeInTimingsReport includeInTimingsReport; + public class IncludeInTimingsReport extends ConfigurationPart { // Gale start - include server.properties in timings @@ -106,4 +107,11 @@ public class GaleGlobalConfiguration extends ConfigurationPart { } + public LogToConsole logToConsole; + public class LogToConsole extends ConfigurationPart { + + public boolean invalidStatistics = true; // Gale - EMC - do not log invalid statistics + + } + }