mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2025-12-19 14:59:29 +00:00
91 lines
5.3 KiB
Diff
91 lines
5.3 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 d2b4654a9095a678bbc9e004af969cf54da0fcab..d797bac97ec1adec7a25a26c8e052e70e8db1c28 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
|
|
@@ -23,10 +23,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;
|
|
@@ -49,7 +50,7 @@ public class PoolElementStructurePiece extends StructurePiece {
|
|
this.position = new BlockPos(nbt.getInt("PosX"), nbt.getInt("PosY"), nbt.getInt("PosZ"));
|
|
this.groundLevelDelta = nbt.getInt("ground_level_delta");
|
|
DynamicOps<Tag> dynamicOps = RegistryOps.create(NbtOps.INSTANCE, context.registryAccess());
|
|
- this.element = StructurePoolElement.CODEC.parse(dynamicOps, nbt.getCompound("pool_element")).resultOrPartial(LOGGER::error).orElseThrow(() -> {
|
|
+ this.element = StructurePoolElement.CODEC.parse(dynamicOps, nbt.getCompound("pool_element")).resultOrPartial(GaleGlobalConfiguration.get().logToConsole.invalidPoolElementErrorStringConsumer).orElseThrow(() -> { // Gale - EMC - softly log invalid pool element errors
|
|
return new IllegalStateException("Invalid pool element found");
|
|
});
|
|
this.rotation = Rotation.valueOf(nbt.getString("rotation"));
|
|
diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
|
index 91776314125f1101b7b67304b55748bda8c6e09b..24c67ac6e8f2572cc2e79350fdf4201825ee9e72 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
|
|
@@ -122,6 +126,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
|
|
+
|
|
}
|
|
|
|
}
|