Files
MiraiMC/patches/server/0039-Logger-settings-suppressing-pointless-logs.patch
2022-07-21 19:36:05 +02:00

106 lines
7.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Sat, 19 Oct 2019 00:52:12 -0500
Subject: [PATCH] Logger settings (suppressing pointless logs)
Original code by PurpurMC, licensed under MIT
You can find the original code on https://github.com/PurpurMC/Purpur
diff --git a/src/main/java/net/minecraft/server/PlayerAdvancements.java b/src/main/java/net/minecraft/server/PlayerAdvancements.java
index de0513b38e5fa0138f1cee6bb633561be12449fc..c0325b9cb56dc09c005c277a8fdc5970b78093f8 100644
--- a/src/main/java/net/minecraft/server/PlayerAdvancements.java
+++ b/src/main/java/net/minecraft/server/PlayerAdvancements.java
@@ -184,7 +184,7 @@ public class PlayerAdvancements {
if (advancement == null) {
// CraftBukkit start
- if (entry.getKey().getNamespace().equals("minecraft")) {
+ if (!wtf.etil.mirai.MiraiConfig.loggerSuppressIgnoredAdvancementWarnings && entry.getKey().getNamespace().equals("minecraft")) { // Purpur
PlayerAdvancements.LOGGER.warn("Ignored advancement '{}' in progress file {} - it doesn't exist anymore?", entry.getKey(), this.file);
}
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
index f000c822ed4563b5b840936852bc7d8e030763e3..4538e459f35d2e08fbacee71cec142a2db4b1371 100644
--- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java
+++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
@@ -294,7 +294,7 @@ public class WorldGenRegion implements WorldGenLevel {
return true;
} else {
// Paper start
- if (!hasSetFarWarned) {
+ if (!wtf.etil.mirai.MiraiConfig.loggerSuppressSetBlockFarChunk && !hasSetFarWarned) { // Purpur
Util.logAndPauseIfInIde("Detected setBlock in a far chunk [" + i + ", " + j + "], pos: " + pos + ", status: " + this.generatingStatus + (this.currentlyGenerating == null ? "" : ", currently generating: " + (String) this.currentlyGenerating.get()));
hasSetFarWarned = true;
if (this.getServer() != null && this.getServer().isDebugging()) {
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 785e9e9b4408c1193cb3680a3b55f90a8f0d5b0a..aa5d0865f4d3c1e68f9fc06e49bea8889318371d 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2182,7 +2182,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
}); // Paper - push to main
return false;
} else {
- if (this.isChatExpired(instant)) {
+ if (!wtf.etil.mirai.MiraiConfig.loggerSuppressSentExpiredChat && this.isChatExpired(instant)) { // Purpur
ServerGamePacketListenerImpl.LOGGER.warn("{} sent expired chat: '{}'. Is the client/server system time unsynchronized? c: {} s: {}", this.player.getName().getString(), s, instant.getEpochSecond(), Instant.now().getEpochSecond()); // Paper
}
diff --git a/src/main/java/net/minecraft/stats/ServerRecipeBook.java b/src/main/java/net/minecraft/stats/ServerRecipeBook.java
index d13ed3069e944d138442ea440ac3eaf8d44c18d3..f87a9e76f098300f68f62ced69cf1c49aef32b69 100644
--- a/src/main/java/net/minecraft/stats/ServerRecipeBook.java
+++ b/src/main/java/net/minecraft/stats/ServerRecipeBook.java
@@ -121,7 +121,7 @@ public class ServerRecipeBook extends RecipeBook {
ResourceLocation minecraftkey = new ResourceLocation(s);
Optional<? extends Recipe<?>> optional = recipeManager.byKey(minecraftkey);
- if (!optional.isPresent()) {
+ if (!wtf.etil.mirai.MiraiConfig.loggerSuppressUnrecognizedRecipeErrors && !optional.isPresent()) { // Purpur
ServerRecipeBook.LOGGER.error("Tried to load unrecognized recipe: {} removed now.", minecraftkey);
} else {
handler.accept((Recipe) optional.get());
diff --git a/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java b/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java
index b2a15c986c7500a0ce227a54cb61ec3f5378f6f3..d243af83f3159d8a4d56d08dab022b317cc5687e 100644
--- a/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java
+++ b/src/main/java/org/bukkit/craftbukkit/legacy/CraftLegacy.java
@@ -255,6 +255,7 @@ public final class CraftLegacy {
}
static {
+ if (!wtf.etil.mirai.MiraiConfig.loggerSuppressInitLegacyMaterialError) // Purpur
System.err.println("Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!");
if (MinecraftServer.getServer() != null && MinecraftServer.getServer().isDebugging()) {
new Exception().printStackTrace();
diff --git a/src/main/java/wtf/etil/mirai/MiraiConfig.java b/src/main/java/wtf/etil/mirai/MiraiConfig.java
index eda02eabbdb3c8d2cfe8c524fe9f5dfcca1089d8..65a77864c368545c14d1bb28fb0a91323e286158 100644
--- a/src/main/java/wtf/etil/mirai/MiraiConfig.java
+++ b/src/main/java/wtf/etil/mirai/MiraiConfig.java
@@ -166,4 +166,27 @@ public class MiraiConfig {
"This can drastically reduce players timeouts due to a bad connection.");
}
+ public static boolean loggerSuppressInitLegacyMaterialError;
+ public static boolean loggerSuppressIgnoredAdvancementWarnings;
+ public static boolean loggerSuppressUnrecognizedRecipeErrors;
+ public static boolean loggerSuppressSetBlockFarChunk;
+ public static boolean loggerSuppressSentExpiredChat;
+ private static void loggerSettings() {
+ loggerSuppressInitLegacyMaterialError = getBoolean("logger.suppress-init-legacy-material-errors", true,
+ "Whether or not server should stop saying",
+ "'Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!'");
+ loggerSuppressIgnoredAdvancementWarnings = getBoolean("logger.suppress-ignored-advancement-warnings", true,
+ "Whether or not server should stop saying",
+ "'Ignored advancement '{}' in progress file {} - it doesn't exist anymore?'");
+ loggerSuppressUnrecognizedRecipeErrors = getBoolean("logger.suppress-unrecognized-recipe-errors", true,
+ "Whether or not server should stop saying",
+ "'Tried to load unrecognized recipe: {} removed now.'");
+ loggerSuppressSetBlockFarChunk = getBoolean("logger.suppress-setblock-in-far-chunk-errors", true,
+ "Whether or not server should stop saying",
+ "'Detected setBlock in a far chunk.'");
+ loggerSuppressSentExpiredChat = getBoolean("logger.suppress-sent-expired-chat", true,
+ "Whether or not server should stop saying",
+ "'{} sent expired chat: '{}'. Is the client/server system time unsynchronized?'");
+ }
+
}
\ No newline at end of file