From 4624839100f3d2a6cbd61d7af875605a50d1366d Mon Sep 17 00:00:00 2001 From: "James (Jamalam)" Date: Sat, 22 Jul 2023 09:46:06 +0100 Subject: [PATCH 1/7] Make mods aware of their location --- .../org/quiltmc/community/cozy/modules/logs/data/Mod.kt | 4 +++- .../cozy/modules/logs/parsers/fabric/FabricModsParser.kt | 3 ++- .../cozy/modules/logs/parsers/quilt/QuiltModsParser.kt | 7 ++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/data/Mod.kt b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/data/Mod.kt index 7674dd01..decb9168 100644 --- a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/data/Mod.kt +++ b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/data/Mod.kt @@ -10,5 +10,7 @@ import org.quiltmc.community.cozy.modules.logs.Version public data class Mod( val id: String, - val version: Version + val version: Version, + // Only present on Quilt Loader + val path: String? ) diff --git a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/parsers/fabric/FabricModsParser.kt b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/parsers/fabric/FabricModsParser.kt index caa9880e..b29fd432 100644 --- a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/parsers/fabric/FabricModsParser.kt +++ b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/parsers/fabric/FabricModsParser.kt @@ -36,7 +36,8 @@ public class FabricModsParser : LogParser() { log.addMod( Mod( split.first(), - Version(split.last()) + Version(split.last()), + null ) ) } diff --git a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/parsers/quilt/QuiltModsParser.kt b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/parsers/quilt/QuiltModsParser.kt index a34695ca..dc0a5608 100644 --- a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/parsers/quilt/QuiltModsParser.kt +++ b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/parsers/quilt/QuiltModsParser.kt @@ -18,6 +18,7 @@ import org.quiltmc.community.cozy.modules.logs.types.LogParser private val OPENING_LINES = arrayOf( "Loading \\d+ mods:\n".toRegex(RegexOption.IGNORE_CASE), "-- Mods --\n".toRegex(RegexOption.IGNORE_CASE), + "-- Mod Table --\n".toRegex(RegexOption.IGNORE_CASE), "\tQuilt Mods: \n".toRegex(RegexOption.IGNORE_CASE), ) @@ -27,8 +28,7 @@ public class QuiltModsParser : LogParser() { override val identifier: String = "mods-quilt" override val order: Order = Order.Default - override suspend fun predicate(log: Log, event: Event): Boolean = - log.getLoaderVersion(LoaderType.Quilt) != null + override suspend fun predicate(log: Log, event: Event): Boolean = log.getLoaderVersion(LoaderType.Quilt) != null override suspend fun process(log: Log) { val openingLine = OPENING_LINES.first { it in log.content } @@ -72,7 +72,8 @@ public class QuiltModsParser : LogParser() { log.addMod( Mod( mod["id"]!!, - Version(mod["version"]!!) + Version(mod["version"]!!), + mod["file(s)"] ) ) } From e4fe355c1ccec7f84b669b441dab6dfc525f219d Mon Sep 17 00:00:00 2001 From: "James (Jamalam)" Date: Sat, 22 Jul 2023 09:46:25 +0100 Subject: [PATCH 2/7] Add processor to request crash reports --- .../logs/processors/CrashReportProcessor.kt | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/CrashReportProcessor.kt diff --git a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/CrashReportProcessor.kt b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/CrashReportProcessor.kt new file mode 100644 index 00000000..28835620 --- /dev/null +++ b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/CrashReportProcessor.kt @@ -0,0 +1,28 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +package org.quiltmc.community.cozy.modules.logs.processors + +import dev.kord.core.event.Event +import org.quiltmc.community.cozy.modules.logs.data.Log +import org.quiltmc.community.cozy.modules.logs.data.Order +import org.quiltmc.community.cozy.modules.logs.types.LogProcessor + +private val CRASH_REPORT_REGEX = "Crashed! The full crash report has been saved to (\\S+)" + .toRegex(RegexOption.IGNORE_CASE) + +public class CrashReportProcessor : LogProcessor() { + override val identifier: String = "crash-reports" + override val order: Order = Order.Default + + override suspend fun predicate(log: Log, event: Event): Boolean = + CRASH_REPORT_REGEX.find(log.content) != null + + override suspend fun process(log: Log) { + val match = CRASH_REPORT_REGEX.find(log.content) ?: return + log.addMessage("Please also provide the crash report at `${match.groups[1]!!.value}`") + } +} From 7314a79a6e36f1cafbd70cee27144fc09ef4fd16 Mon Sep 17 00:00:00 2001 From: "James (Jamalam)" Date: Sat, 22 Jul 2023 09:46:51 +0100 Subject: [PATCH 3/7] Add fabric apis on quilt processor --- .../processors/quilt/FabricApisProcessor.kt | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/quilt/FabricApisProcessor.kt diff --git a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/quilt/FabricApisProcessor.kt b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/quilt/FabricApisProcessor.kt new file mode 100644 index 00000000..5c54f030 --- /dev/null +++ b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/quilt/FabricApisProcessor.kt @@ -0,0 +1,43 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +package org.quiltmc.community.cozy.modules.logs.processors.quilt + +import dev.kord.core.event.Event +import org.quiltmc.community.cozy.modules.logs.data.LoaderType +import org.quiltmc.community.cozy.modules.logs.data.Log +import org.quiltmc.community.cozy.modules.logs.data.Order +import org.quiltmc.community.cozy.modules.logs.types.LogProcessor + +public class FabricApisProcessor : LogProcessor() { + override val identifier: String = "quilt-fabric-apis" + override val order: Order = Order.Default + + override suspend fun predicate(log: Log, event: Event): Boolean = + log.getLoaderVersion(LoaderType.Quilt) != null + + override suspend fun process(log: Log) { + val fabricApi = log.getMod("fabric") + val fabricLanguageKotlin = log.getMod("fabric-language-kotlin") + + if (fabricApi != null) { + log.hasProblems = true + + log.addMessage( + "Fabric API is present at `${fabricApi.path}`, and should be replaced by [QSL](https://modrinth.com/mod/qsl)" + ) + } + + if (fabricLanguageKotlin != null) { + log.hasProblems = true + + log.addMessage( + "Fabric Language Kotlin is present at `${fabricLanguageKotlin.path}`, " + + "and should be replaced by [QKL](https://modrinth.com/mod/qkl)" + ) + } + } +} From 7ced10d8de5d539c765ed3b58c943b458946e174 Mon Sep 17 00:00:00 2001 From: "James (Jamalam)" Date: Sat, 22 Jul 2023 09:47:08 +0100 Subject: [PATCH 4/7] Add the two new processors --- .../modules/logs/config/SimpleLogParserConfig.kt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/config/SimpleLogParserConfig.kt b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/config/SimpleLogParserConfig.kt index 35dde5cf..22a0d23f 100644 --- a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/config/SimpleLogParserConfig.kt +++ b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/config/SimpleLogParserConfig.kt @@ -16,14 +16,8 @@ import org.quiltmc.community.cozy.modules.logs.parsers.launchers.ATLauncherParse import org.quiltmc.community.cozy.modules.logs.parsers.launchers.MMCLikeParser import org.quiltmc.community.cozy.modules.logs.parsers.launchers.TechnicParser import org.quiltmc.community.cozy.modules.logs.parsers.quilt.QuiltModsParser -import org.quiltmc.community.cozy.modules.logs.processors.JavaClassFileVersionProcessor -import org.quiltmc.community.cozy.modules.logs.processors.MixinErrorProcessor -import org.quiltmc.community.cozy.modules.logs.processors.PlayerIPProcessor -import org.quiltmc.community.cozy.modules.logs.processors.UnknownModProcessor -import org.quiltmc.community.cozy.modules.logs.processors.quilt.FabricImplProcessor -import org.quiltmc.community.cozy.modules.logs.processors.quilt.IncompatibleModProcessor -import org.quiltmc.community.cozy.modules.logs.processors.quilt.QuiltLibrariesVersionProcessor -import org.quiltmc.community.cozy.modules.logs.processors.quilt.QuiltLoaderVersionProcessor +import org.quiltmc.community.cozy.modules.logs.processors.* +import org.quiltmc.community.cozy.modules.logs.processors.quilt.* import org.quiltmc.community.cozy.modules.logs.retrievers.AttachmentLogRetriever import org.quiltmc.community.cozy.modules.logs.retrievers.PastebinLogRetriever import org.quiltmc.community.cozy.modules.logs.types.LogParser @@ -54,8 +48,10 @@ public class SimpleLogParserConfig(private val builder: Builder) : LogParserConf ) public var processors: MutableList = mutableListOf( + FabricApisProcessor(), FabricImplProcessor(), IncompatibleModProcessor(), + CrashReportProcessor(), JavaClassFileVersionProcessor(), MixinErrorProcessor(), PlayerIPProcessor(), From d50d0d43764f9d699dd191a317474a0fe5c88d16 Mon Sep 17 00:00:00 2001 From: "James (Jamalam)" Date: Sat, 22 Jul 2023 09:47:30 +0100 Subject: [PATCH 5/7] Fix some names --- .../modules/logs/processors/JavaClassFileVersionProcessor.kt | 2 +- .../cozy/modules/logs/processors/MixinErrorProcessor.kt | 2 +- .../cozy/modules/logs/processors/UnknownModProcessor.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/JavaClassFileVersionProcessor.kt b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/JavaClassFileVersionProcessor.kt index 1489a6f0..33fdd0aa 100644 --- a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/JavaClassFileVersionProcessor.kt +++ b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/JavaClassFileVersionProcessor.kt @@ -45,7 +45,7 @@ private val VERSION_MAP = mutableMapOf( ) public class JavaClassFileVersionProcessor : LogProcessor() { - override val identifier: String = "piracy" + override val identifier: String = "java-class-file-version" override val order: Order = Order.Earlier override suspend fun predicate(log: Log, event: Event): Boolean = diff --git a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/MixinErrorProcessor.kt b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/MixinErrorProcessor.kt index 0b2a3771..02c1dad6 100644 --- a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/MixinErrorProcessor.kt +++ b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/MixinErrorProcessor.kt @@ -23,7 +23,7 @@ private val MIXIN_ERROR_REGEXES = arrayOf( ) public class MixinErrorProcessor : LogProcessor() { - override val identifier: String = "piracy" + override val identifier: String = "mixin-error" override val order: Order = Order.Earlier override suspend fun process(log: Log) { diff --git a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/UnknownModProcessor.kt b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/UnknownModProcessor.kt index 0802155c..76ab1cd6 100644 --- a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/UnknownModProcessor.kt +++ b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/UnknownModProcessor.kt @@ -16,7 +16,7 @@ import org.quiltmc.community.cozy.modules.logs.types.LogProcessor private val UNKNOWN_MOD_REGEX = "Unknown file in mods folder: [\\\\/]([^\n]+)\n".toRegex(RegexOption.IGNORE_CASE) public class UnknownModProcessor : LogProcessor() { - override val identifier: String = "piracy" + override val identifier: String = "unknown-mod" override val order: Order = Order.Earlier override suspend fun predicate(log: Log, event: Event): Boolean = From 0b5ec2fed8a5d523013ef23a26c226bc96c488fc Mon Sep 17 00:00:00 2001 From: "James (Jamalam)" Date: Sat, 22 Jul 2023 09:48:21 +0100 Subject: [PATCH 6/7] Update regexes This allows parsing crash report mod tables, it wasn't working before. The change doesn't break anything --- .../quiltmc/community/cozy/modules/logs/parsers/LoaderParser.kt | 2 +- .../cozy/modules/logs/parsers/MinecraftVersionParser.kt | 2 +- .../logs/processors/quilt/QuiltLoaderVersionProcessor.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/parsers/LoaderParser.kt b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/parsers/LoaderParser.kt index e1d9d0a7..8aca3ce8 100644 --- a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/parsers/LoaderParser.kt +++ b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/parsers/LoaderParser.kt @@ -13,7 +13,7 @@ import org.quiltmc.community.cozy.modules.logs.data.Order import org.quiltmc.community.cozy.modules.logs.types.LogParser private val PATTERNS = mapOf( - "\n\\|[\\s\\d]+\\| Quilt Loader\\s+\\| quilt_loader\\s+\\| (\\S+).+\n" + "\\| Quilt Loader\\s+\\| quilt_loader\\s+\\| (\\S+).+" .toRegex(RegexOption.IGNORE_CASE) to LoaderType.Quilt, // Quilt mods table ": Loading .+ with Quilt Loader (\\S+)".toRegex(RegexOption.IGNORE_CASE) to LoaderType.Quilt, diff --git a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/parsers/MinecraftVersionParser.kt b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/parsers/MinecraftVersionParser.kt index c3a269ea..65e95bbc 100644 --- a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/parsers/MinecraftVersionParser.kt +++ b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/parsers/MinecraftVersionParser.kt @@ -14,7 +14,7 @@ import org.quiltmc.community.cozy.modules.logs.types.LogParser private val PATTERNS = listOf( // Impossible to do this for vanilla; the logs don't contain the MC version for some reason - "\n\\|[\\s\\d]+\\| Minecraft\\s+\\| minecraft\\s+\\| (\\S+).+\n" + "\\| Minecraft\\s+\\| minecraft\\s+\\| (\\S+).+" .toRegex(RegexOption.IGNORE_CASE), // Quilt mods table ": Loading Minecraft (\\S+)".toRegex(RegexOption.IGNORE_CASE), // Fabric, Quilt diff --git a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/quilt/QuiltLoaderVersionProcessor.kt b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/quilt/QuiltLoaderVersionProcessor.kt index b3993473..a8a40891 100644 --- a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/quilt/QuiltLoaderVersionProcessor.kt +++ b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/processors/quilt/QuiltLoaderVersionProcessor.kt @@ -15,7 +15,7 @@ import org.quiltmc.community.cozy.modules.logs.data.Order import org.quiltmc.community.cozy.modules.logs.types.LogProcessor public class QuiltLoaderVersionProcessor : LogProcessor() { - override val identifier: String = "fabric-loader-version" + override val identifier: String = "quilt-loader-version" override val order: Order = Order.Default private val metaClient = QuiltMetaClient() From 3835b50edfcc126938dd462f0284cf0272faca25 Mon Sep 17 00:00:00 2001 From: "James (Jamalam)" Date: Sat, 22 Jul 2023 09:48:29 +0100 Subject: [PATCH 7/7] Update regexes This allows parsing crash report mod tables, it wasn't working before. The change doesn't break anything --- module-log-parser/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/module-log-parser/README.md b/module-log-parser/README.md index 147d5884..3c92627f 100644 --- a/module-log-parser/README.md +++ b/module-log-parser/README.md @@ -34,6 +34,7 @@ yourself. - Detection for mods that make use of internal Fabric types - Detection for mods that are marked incompatible on [Quilt's forum](https://forum.quiltmc.org/t/mod-incompatibility-megathread/261) - Detection for out-of-date installations of Quilt Loader and QSL/QFAPI + - Detection for the presence of Fabric API or Fabric Language Kotlin - **Piracy launcher detection (optional):** Bails when authentication fails or TLauncher is detected - **Player IP warning:** Warns users when they upload a log containing player IP addresses - **Problematic launcher detection (optional):** Bails when PolyMC is detected and explains why it shouldn't be used