9
0
mirror of https://github.com/Dreeam-qwq/Gale.git synced 2025-12-22 16:29:26 +00:00
Files
Gale/patches/server/0067-Softly-log-invalid-pool-element-errors.patch
2024-04-28 08:17:49 -04:00

91 lines
5.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Fri, 25 Nov 2022 16:26:04 +0100
Subject: [PATCH] Softly log invalid pool element errors
License: MIT (https://opensource.org/licenses/MIT)
Gale - https://galemc.org
This patch is based on the following patch:
"Change vanilla structure error to info log level"
By: chickeneer <emcchickeneer@gmail.com>
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/world/level/levelgen/structure/PoolElementStructurePiece.java b/src/main/java/net/minecraft/world/level/levelgen/structure/PoolElementStructurePiece.java
index 608cfb0db7bb14611f6cdcb55d9701a55d882e9d..64ee66ba5e3340ac10f060d950f3515ac893bd55 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/structure/PoolElementStructurePiece.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/structure/PoolElementStructurePiece.java
@@ -22,10 +22,11 @@ import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceType;
import net.minecraft.world.level.levelgen.structure.pools.JigsawJunction;
import net.minecraft.world.level.levelgen.structure.pools.StructurePoolElement;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager;
+import org.galemc.gale.configuration.GaleGlobalConfiguration;
import org.slf4j.Logger;
public class PoolElementStructurePiece extends StructurePiece {
- private static final Logger LOGGER = LogUtils.getLogger();
+ public static final Logger LOGGER = LogUtils.getLogger(); // Gale - EMC - softly log invalid pool element errors - private -> public
protected final StructurePoolElement element;
protected BlockPos position;
private final int groundLevelDelta;
@@ -57,7 +58,7 @@ public class PoolElementStructurePiece extends StructurePiece {
DynamicOps<Tag> dynamicOps = context.registryAccess().createSerializationContext(NbtOps.INSTANCE);
this.element = StructurePoolElement.CODEC
.parse(dynamicOps, nbt.getCompound("pool_element"))
- .resultOrPartial(LOGGER::error)
+ .resultOrPartial(GaleGlobalConfiguration.get().logToConsole.invalidPoolElementErrorStringConsumer) // Gale - EMC - softly log invalid pool element errors
.orElseThrow(() -> new IllegalStateException("Invalid pool element found"));
this.rotation = Rotation.valueOf(nbt.getString("rotation"));
this.boundingBox = this.element.getBoundingBox(this.structureTemplateManager, this.position, this.rotation);
diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
index d95141f43ebbad984db96416623957bd47f3ac1b..ea7f6a826763af8aa10d79e82b9ba99198e31e06 100644
--- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
@@ -4,10 +4,14 @@ package org.galemc.gale.configuration;
import io.papermc.paper.configuration.Configuration;
import io.papermc.paper.configuration.ConfigurationPart;
+import net.minecraft.world.level.levelgen.structure.PoolElementStructurePiece;
import org.bukkit.plugin.java.JavaPluginLoader;
import org.spongepowered.configurate.objectmapping.meta.PostProcess;
import org.spongepowered.configurate.objectmapping.meta.Setting;
+import java.util.Locale;
+import java.util.function.Consumer;
+
@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic"})
public class GaleGlobalConfiguration extends ConfigurationPart {
static final int CURRENT_VERSION = 1;
@@ -87,7 +91,7 @@ public class GaleGlobalConfiguration extends ConfigurationPart {
}
public LogToConsole logToConsole;
- public class LogToConsole extends ConfigurationPart {
+ public class LogToConsole extends ConfigurationPart { // Gale - EMC - softly log invalid pool element errors
public boolean invalidStatistics = true; // Gale - EMC - do not log invalid statistics
public boolean ignoredAdvancements = true; // Gale - Purpur - do not log ignored advancements
@@ -121,6 +125,21 @@ public class GaleGlobalConfiguration extends ConfigurationPart {
}
// Gale end - Purpur - do not log plugin library loads
+ // Gale start - EMC - softly log invalid pool element errors
+ public String invalidPoolElementErrorLogLevel = "info";
+ public transient Consumer<String> invalidPoolElementErrorStringConsumer;
+
+ @PostProcess
+ public void postProcess() {
+ this.invalidPoolElementErrorStringConsumer = switch (this.invalidPoolElementErrorLogLevel.toLowerCase(Locale.ROOT)) {
+ case "none" -> $ -> {};
+ case "info", "log" -> PoolElementStructurePiece.LOGGER::info;
+ case "warn", "warning" -> PoolElementStructurePiece.LOGGER::warn;
+ default -> PoolElementStructurePiece.LOGGER::error;
+ };
+ }
+ // Gale end - EMC - softly log invalid pool element errors
+
}
}