diff --git a/src/model/struct/model/module/forgemod/forgemod113.struct.ts b/src/model/struct/model/module/forgemod/forgemod113.struct.ts index 796a8f3..ae445f3 100644 --- a/src/model/struct/model/module/forgemod/forgemod113.struct.ts +++ b/src/model/struct/model/module/forgemod/forgemod113.struct.ts @@ -8,6 +8,8 @@ import { BaseForgeModStructure } from '../forgemod.struct' export class ForgeModStructure113 extends BaseForgeModStructure { + public static readonly IMPLEMENTATION_VERSION_REGEX = /^Implementation-Version: (.+)[\r\n]/ + public static isForVersion(version: string) { return VersionUtil.isVersionAcceptable(version, [13, 14, 15]) } @@ -73,7 +75,26 @@ export class ForgeModStructure113 extends BaseForgeModStructure { if (raw) { // Assuming the main mod will be the first entry in this file. try { - this.forgeModMetadata[name] = toml.parse(raw) as ModsToml + const parsed = toml.parse(raw) as ModsToml + + // tslint:disable-next-line: no-invalid-template-strings + if (parsed.mods[0].version === '${file.jarVersion}') { + let version = '0.0.0' + const manifest = zip.readAsText('META-INF/MANIFEST.MF') + const keys = manifest.split('\n') + console.log(keys) + for (const key of keys) { + const match = ForgeModStructure113.IMPLEMENTATION_VERSION_REGEX.exec(key) + if (match != null) { + version = match[1] + } + } + console.debug(`ForgeMod ${name} contains a version wildcard, inferring ${version}`) + parsed.mods[0].version = version + } + + this.forgeModMetadata[name] = parsed + } catch (err) { console.error(`ForgeMod ${name} contains an invalid mods.toml file.`) createDefault = true