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 fb7342f7a5008a283c3400c6313c637de8210dfa..a45353b8a6dd85c74d3e195f89f75f2509d579ad 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 { @@ -137,15 +138,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 8075e5c17f469f1bf5b7758a1334943d6ed8383f..56aa01dfbfc0817b71315322ed3f676bd62ad825 100644 --- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java +++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java @@ -47,4 +47,11 @@ public class GaleGlobalConfiguration extends ConfigurationPart { public boolean verifyChatOrder = true; // Gale - Pufferfish - make chat order verification configurable } + + public LogToConsole logToConsole; + public class LogToConsole extends ConfigurationPart { + + public boolean invalidStatistics = true; // Gale - EMC - do not log invalid statistics + + } }