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 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(), 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/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/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)"] ) ) } 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}`") + } +} 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 = 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)" + ) + } + } +} 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()