From 2baf74ebf0c93b240f0d0006ad2b5a25e565e252 Mon Sep 17 00:00:00 2001 From: ix0rai Date: Tue, 1 Aug 2023 17:22:48 -0500 Subject: [PATCH] Only apply prism message to versions that require it (#73) --- .../community/cozy/modules/logs/data/Log.kt | 1 + .../modules/logs/parsers/LauncherParser.kt | 25 ++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/data/Log.kt b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/data/Log.kt index 1e03e5ef..a5ed5078 100644 --- a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/data/Log.kt +++ b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/data/Log.kt @@ -16,6 +16,7 @@ public typealias Logs = List public open class Log { public val environment: Environment = Environment() public var launcher: Launcher? = null + public var launcherVersion: String? = null public var url: URL? = null public val extraEmbeds: MutableList Unit> = mutableListOf() diff --git a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/parsers/LauncherParser.kt b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/parsers/LauncherParser.kt index ff72323a..4c9e2b52 100644 --- a/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/parsers/LauncherParser.kt +++ b/module-log-parser/src/main/kotlin/org/quiltmc/community/cozy/modules/logs/parsers/LauncherParser.kt @@ -6,6 +6,7 @@ package org.quiltmc.community.cozy.modules.logs.parsers +import com.github.zafarkhaja.semver.Version import org.quiltmc.community.cozy.modules.logs.data.Launcher import org.quiltmc.community.cozy.modules.logs.data.Log import org.quiltmc.community.cozy.modules.logs.data.Order @@ -36,13 +37,25 @@ public class LauncherParser : LogParser() { log.launcher = Launcher(launcher, match!!.groups[1]?.value) - if (launcher == Launcher.Prism) { - log.addMessage( - "**It looks like you're using Prism.** Please note that Prism [currently breaks uploaded logs]" + + // MultiMC-derived launchers declare their version in the log, so we can parse it + if (launcher == Launcher.MultiMC || launcher == Launcher.PolyMC || launcher == Launcher.Prism) { + val message: String? = match.groups[1]?.value + if (message != null) { + log.launcherVersion = message.split("version: ")[1] + } + } + + if (launcher == Launcher.Prism && log.launcherVersion != null) { + val version: Version = Version.valueOf(log.launcherVersion!!) + if (version.compareTo(Version.valueOf("7.0")) < 0) { + log.addMessage( + "**It looks like you're using an outdated version of Prism.** +" + + "Please note that Prism [formerly broke uploaded logs]" + "(https://github.com/PrismLauncher/PrismLauncher/issues/930), and the information " + - "provided here may be incomplete. Until this is fixed, please consider manually " + - "uploading your `latest.log` file to the channel instead." - ) + "provided here may be incomplete. Please either update Prism to 7.0+ or manually " + + "upload your `latest.log` file to the channel instead." + ) + } } } }