aboutsummaryrefslogtreecommitdiff
path: root/api/logic/minecraft/mod/LocalModParseTask.cpp
diff options
context:
space:
mode:
authorkumquat-ir <66188216+kumquat-ir@users.noreply.github.com>2021-04-16 17:45:55 -0700
committerkumquat-ir <66188216+kumquat-ir@users.noreply.github.com>2021-04-16 17:45:55 -0700
commit13afad80fb9b17503621dc63509113203af8887c (patch)
treeb80f9d6cf05c0e5f302bcbab83f2c27996da327b /api/logic/minecraft/mod/LocalModParseTask.cpp
parent7156e086f6ba6993db87396e133b8158bed882c8 (diff)
downloadPrismLauncher-13afad80fb9b17503621dc63509113203af8887c.tar.gz
PrismLauncher-13afad80fb9b17503621dc63509113203af8887c.tar.bz2
PrismLauncher-13afad80fb9b17503621dc63509113203af8887c.zip
replace ${file.jarVersion} with something useful
Diffstat (limited to 'api/logic/minecraft/mod/LocalModParseTask.cpp')
-rw-r--r--api/logic/minecraft/mod/LocalModParseTask.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/api/logic/minecraft/mod/LocalModParseTask.cpp b/api/logic/minecraft/mod/LocalModParseTask.cpp
index cb35dca6..9f3da5a7 100644
--- a/api/logic/minecraft/mod/LocalModParseTask.cpp
+++ b/api/logic/minecraft/mod/LocalModParseTask.cpp
@@ -267,6 +267,43 @@ void LocalModParseTask::processAsZip()
m_result->details = ReadMCModTOML(file.readAll());
file.close();
+
+ // to replace ${file.jarVersion} with the actual version, as needed
+ if (m_result->details && m_result->details->version == "${file.jarVersion}")
+ {
+ if (zip.setCurrentFile("META-INF/MANIFEST.MF"))
+ {
+ if (!file.open(QIODevice::ReadOnly))
+ {
+ zip.close();
+ return;
+ }
+
+ // quick and dirty line-by-line parser
+ auto manifestLines = file.readAll().split('\n');
+ QString manifestVersion = "";
+ for (auto &line : manifestLines)
+ {
+ if (QString(line).startsWith("Implementation-Version: "))
+ {
+ manifestVersion = QString(line).remove("Implementation-Version: ");
+ break;
+ }
+ }
+
+ // some mods use ${projectversion} in their build.gradle, causing this mess to show up in MANIFEST.MF
+ // also keep with forge's behavior of setting the version to "NONE" if none is found
+ if (manifestVersion.contains("task ':jar' property 'archiveVersion'") || manifestVersion == "")
+ {
+ manifestVersion = "NONE";
+ }
+
+ m_result->details->version = manifestVersion;
+
+ file.close();
+ }
+ }
+
zip.close();
return;
}