From c51512f94036b7d13b98cb02b8e8c1e549e7b448 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Wed, 27 Sep 2017 15:39:13 +0200 Subject: NOISSUE use classparser for importing Legacy instances with undecided Minecraft versions --- api/logic/minecraft/legacy/LegacyUpgradeTask.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'api/logic/minecraft/legacy/LegacyUpgradeTask.cpp') diff --git a/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp b/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp index cb0572ed..e41d87cb 100644 --- a/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp +++ b/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp @@ -8,6 +8,7 @@ #include "LegacyInstance.h" #include "minecraft/MinecraftInstance.h" #include "minecraft/MinecraftProfile.h" +#include "classparser.h" LegacyUpgradeTask::LegacyUpgradeTask(SettingsObjectPtr settings, const QString & stagingPath, InstancePtr origInstance, const QString & newName) { @@ -50,7 +51,6 @@ static QString decideVersion(const QString& currentVersion, const QString& inten return intendedVersion; } } - // TODO: possibly add fallback to the old jar/classfile analysis method from MultiMC4 return QString(); } @@ -74,9 +74,17 @@ void LegacyUpgradeTask::copyFinished() QString preferredVersionNumber = decideVersion(legacyInst->currentVersionId(), legacyInst->intendedVersionId()); if(preferredVersionNumber.isNull()) { - // FIXME: let the user decide - emitFailed(tr("Could not decide Minecraft version.")); - return; + // try to decide version based on the jar(s?) + preferredVersionNumber = classparser::GetMinecraftJarVersion(legacyInst->baseJar()); + if(preferredVersionNumber.isNull()) + { + preferredVersionNumber = classparser::GetMinecraftJarVersion(legacyInst->runnableJar()); + if(preferredVersionNumber.isNull()) + { + emitFailed(tr("Could not decide Minecraft version.")); + return; + } + } } inst->setComponentVersion("net.minecraft", preferredVersionNumber); -- cgit v1.2.3