diff options
author | Lorenz <lo.scherf@gmail.com> | 2022-09-15 15:34:30 +0200 |
---|---|---|
committer | Lorenz <lo.scherf@gmail.com> | 2022-09-15 15:34:30 +0200 |
commit | 7036145597c0059433c02a047bbf59096ed1d244 (patch) | |
tree | ee5a8e8bf1b53b0e03efbbad63ab287f9a9f0d81 /src/main/java/at | |
parent | 839c398abc36313b1daed2b5d41d3e6d5dc3709a (diff) | |
download | skyhanni-7036145597c0059433c02a047bbf59096ed1d244.tar.gz skyhanni-7036145597c0059433c02a047bbf59096ed1d244.tar.bz2 skyhanni-7036145597c0059433c02a047bbf59096ed1d244.zip |
added more mc console filters
Diffstat (limited to 'src/main/java/at')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/features/DevData.java | 36 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/MinecraftConsoleFilter.kt | 63 |
2 files changed, 68 insertions, 31 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/DevData.java b/src/main/java/at/hannibal2/skyhanni/config/features/DevData.java index f218929cb..30672ac2e 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/DevData.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/DevData.java @@ -34,15 +34,21 @@ public class DevData { public boolean minecraftConsole = false; @Expose - @ConfigOption(name = "Unfiltered Debug", desc = "Print the debug information for unfiltered console messages") + @ConfigOption(name = "Unfiltered Debug", desc = "Print the debug information for unfiltered console messages.") @ConfigEditorBoolean @ConfigAccordionId(id = 1) public boolean printUnfilteredDebugs = false; @Expose + @ConfigOption(name = "Unfiltered Debug File", desc = "Print the debug information into log files instead of into the console for unfiltered console messages.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 1) + public boolean logUnfilteredFile = false; + + @Expose @ConfigOption( name = "Outside SkyBlock", - desc = "Print the debug information for unfiltered console messages outside SkyBlock too" + desc = "Print the debug information for unfiltered console messages outside SkyBlock too." ) @ConfigEditorBoolean @ConfigAccordionId(id = 1) @@ -51,7 +57,7 @@ public class DevData { @Expose @ConfigOption( name = "Log Filtered", - desc = "Log the filtered messages into the console" + desc = "Log the filtered messages into the console." ) @ConfigEditorBoolean @ConfigAccordionId(id = 1) @@ -64,7 +70,7 @@ public class DevData { public boolean consoleFilters = false; @Expose - @ConfigOption(name = "Filter Chat", desc = "Filter chat messages") + @ConfigOption(name = "Filter Chat", desc = "Filter chat messages.") @ConfigEditorBoolean @ConfigAccordionId(id = 2) public boolean filterChat = false; @@ -76,33 +82,45 @@ public class DevData { public boolean filterGrowBuffer = false; @Expose - @ConfigOption(name = "Filter Sound Error", desc = "Filter 'Unable to play unknown soundEvent'") + @ConfigOption(name = "Filter Sound Error", desc = "Filter 'Unable to play unknown soundEvent'.") @ConfigEditorBoolean @ConfigAccordionId(id = 2) public boolean filterUnknownSound = false; @Expose @ConfigOption(name = "Filter Scoreboard Errors", desc = "Filter error messages with Scoreboard: removeTeam, createTeam, " + - "removeObjective and 'scoreboard team already exists'") + "removeObjective and 'scoreboard team already exists'.") @ConfigEditorBoolean @ConfigAccordionId(id = 2) public boolean filterScoreboardErrors = false; @Expose - @ConfigOption(name = "Filter Particle", desc = "Filter message 'Could not spawn particle effect VILLAGER_HAPPY'") + @ConfigOption(name = "Filter Particle", desc = "Filter message 'Could not spawn particle effect VILLAGER_HAPPY'.") @ConfigEditorBoolean @ConfigAccordionId(id = 2) public boolean filterParticleVillagerHappy = false; @Expose - @ConfigOption(name = "Filter OptiFine", desc = "Filter OptiFine messages CustomItems and ConnectedTextures during loading") + @ConfigOption(name = "Filter OptiFine", desc = "Filter OptiFine messages CustomItems and ConnectedTextures during loading.") @ConfigEditorBoolean @ConfigAccordionId(id = 2) public boolean filterOptiFine = false; @Expose - @ConfigOption(name = "Filter AsmHelper Transformer", desc = "Filter messages when AsmHelper is Transforming a class during loading") + @ConfigOption(name = "Filter AsmHelper Transformer", desc = "Filter messages when AsmHelper is Transforming a class during loading.") @ConfigEditorBoolean @ConfigAccordionId(id = 2) public boolean filterAmsHelperTransformer = false; + + @Expose + @ConfigOption(name = "Filter Applying AsmWriter", desc = "Filter messages when AsmHelper is applying AsmWriter ModifyWriter.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean filterAsmHelperApplying = false; + + @Expose + @ConfigOption(name = "Filter Biome ID Bounds", desc = "Filter message 'Biome ID is out of bounds'.") + @ConfigEditorBoolean + @ConfigAccordionId(id = 2) + public boolean filterBiomeIdBounds = false; } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/MinecraftConsoleFilter.kt b/src/main/java/at/hannibal2/skyhanni/utils/MinecraftConsoleFilter.kt index b66ed2387..4ac0a78e8 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/MinecraftConsoleFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/MinecraftConsoleFilter.kt @@ -9,10 +9,14 @@ import org.apache.logging.log4j.core.LogEvent import org.apache.logging.log4j.core.Logger import org.apache.logging.log4j.core.LoggerContext import org.apache.logging.log4j.message.Message +import java.util.regex.Pattern class MinecraftConsoleFilter(private val loggerConfigName: String) : Filter { - val lorenzLogger = LorenzLogger("debug/mc_console_log") + private val loggerFiltered = LorenzLogger("debug/mc_console/filtered") + private val loggerUnfiltered = LorenzLogger("debug/mc_console/unfiltered") + + private val patternBiomeIdBounds = Pattern.compile("Biome ID is out of bounds: (\\d+), defaulting to 0 \\(Ocean\\)") companion object { @JvmStatic @@ -30,7 +34,7 @@ class MinecraftConsoleFilter(private val loggerConfigName: String) : Filter { if (event == null) return Filter.Result.ACCEPT val loggerName = event.loggerName - if (loggerName == "skyhanni") return Filter.Result.ACCEPT + if (loggerName == "SkyHanni") return Filter.Result.ACCEPT val message = event.message val formattedMessage = message.formattedMessage @@ -72,13 +76,19 @@ class MinecraftConsoleFilter(private val loggerConfigName: String) : Filter { return Filter.Result.DENY } } - if (SkyHanniMod.feature.dev.filterAmsHelperTransformer) { - if (loggerName == "AsmHelper") { + if (loggerName == "AsmHelper") { + if (SkyHanniMod.feature.dev.filterAmsHelperTransformer) { if (formattedMessage.startsWith("Transforming class ")) { filterConsole("AsmHelper Transforming") return Filter.Result.DENY } } + if (SkyHanniMod.feature.dev.filterAsmHelperApplying) { + if (formattedMessage.startsWith("Applying AsmWriter ModifyWriter")) { + filterConsole("AsmHelper Applying AsmWriter") + return Filter.Result.DENY + } + } } //TODO find a way to load the filter earlier to filter these messages too // if (loggerName == "LaunchWrapper") { @@ -108,6 +118,12 @@ class MinecraftConsoleFilter(private val loggerConfigName: String) : Filter { // return Filter.Result.DENY // } // } + if (SkyHanniMod.feature.dev.filterBiomeIdBounds) { + if (patternBiomeIdBounds.matcher(formattedMessage).matches()) { + filterConsole("Biome ID bounds") + return Filter.Result.DENY + } + } if (thrown != null) { val cause = thrown.cause @@ -142,52 +158,58 @@ class MinecraftConsoleFilter(private val loggerConfigName: String) : Filter { if (!SkyHanniMod.feature.dev.printUnfilteredDebugsOutsideSkyBlock && !LorenzUtils.inSkyblock) return Filter.Result.ACCEPT if (formattedMessage == "filtered console: ") return Filter.Result.ACCEPT - LorenzUtils.consoleLog(" ") - LorenzUtils.consoleLog("filter 4/event ('$loggerConfigName'/'$loggerName')") - LorenzUtils.consoleLog("formattedMessage: '$formattedMessage'") + debug(" ") + debug("filter 4/event ('$loggerConfigName'/'$loggerName')") + debug("formattedMessage: '$formattedMessage'") val threadName = event.threadName - LorenzUtils.consoleLog("threadName: '$threadName'") + debug("threadName: '$threadName'") val level = event.level - LorenzUtils.consoleLog("level: '$level'") + debug("level: '$level'") val marker = event.marker if (marker != null) { val name = marker.name - LorenzUtils.consoleLog("marker name: '$name'") + debug("marker name: '$name'") } else { - LorenzUtils.consoleLog("marker is null") + debug("marker is null") } - LorenzUtils.consoleLog("thrown: '$thrown'") + debug("thrown: '$thrown'") if (thrown != null) { if (thrown.stackTrace.isNotEmpty()) { var element = thrown.stackTrace[0] - LorenzUtils.consoleLog("thrown first element: '$element'") + debug("thrown first element: '$element'") val cause = thrown.cause if (cause != null) { - LorenzUtils.consoleLog("throw cause: '$cause'") + debug("throw cause: '$cause'") element = cause.stackTrace[0] - LorenzUtils.consoleLog("thrown cause first element: '$element'") + debug("thrown cause first element: '$element'") } } } - LorenzUtils.consoleLog(" ") + debug(" ") return Filter.Result.ACCEPT } + private fun debug(text: String) { + if (SkyHanniMod.feature.dev.logUnfilteredFile) { + loggerUnfiltered.log(text) + } else { + LorenzUtils.consoleLog(text) + } + } + private fun filterConsole(message: String) { - lorenzLogger.log(message) + loggerFiltered.log(message) if (SkyHanniMod.feature.dev.printFilteredReason) { LorenzUtils.consoleLog("filtered console: $message") } } override fun getOnMismatch(): Filter.Result { - LorenzUtils.consoleLog("getOnMismatch ($loggerConfigName)") return Filter.Result.DENY } override fun getOnMatch(): Filter.Result { - LorenzUtils.consoleLog("getOnMatch ($loggerConfigName)") return Filter.Result.ACCEPT } @@ -198,7 +220,6 @@ class MinecraftConsoleFilter(private val loggerConfigName: String) : Filter { msg: String?, vararg params: Any?, ): Filter.Result { - LorenzUtils.consoleLog("filter 1 ($loggerConfigName)") return Filter.Result.ACCEPT } @@ -209,7 +230,6 @@ class MinecraftConsoleFilter(private val loggerConfigName: String) : Filter { msg: Any?, t: Throwable?, ): Filter.Result { - LorenzUtils.consoleLog("filter 2 ($loggerConfigName)") return Filter.Result.ACCEPT } @@ -220,7 +240,6 @@ class MinecraftConsoleFilter(private val loggerConfigName: String) : Filter { msg: Message?, t: Throwable?, ): Filter.Result { - LorenzUtils.consoleLog("filter 3 ($loggerConfigName)") return Filter.Result.ACCEPT } } |