9
0
mirror of https://github.com/Dreeam-qwq/Gale.git synced 2025-12-20 07:19:31 +00:00
This commit is contained in:
Dreeam
2024-06-16 07:45:50 +08:00
parent 4f9a205c95
commit f5bb97f315
106 changed files with 29 additions and 65 deletions

View File

@@ -0,0 +1,86 @@
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 0977cd0d65dd1c2dde04d318759458abe452847e..ee5b317e87c4d403b6d7f5ab1d493e446f9278f6 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
@@ -27,7 +27,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemp
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;
@@ -80,7 +80,7 @@ public class PoolElementStructurePiece extends StructurePiece {
DynamicOps<Tag> dynamicOps = context.registryAccess().createSerializationContext(NbtOps.INSTANCE);
StructurePoolElement.CODEC
.encodeStart(dynamicOps, this.element)
- .resultOrPartial(LOGGER::error)
+ .resultOrPartial(org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.invalidPoolElementErrorStringConsumer) // Gale - EMC - softly log invalid pool element errors
.ifPresent(poolElement -> nbt.put("pool_element", poolElement));
nbt.putString("rotation", this.rotation.name());
ListTag listTag = new ListTag();
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
+
}
}