diff options
Diffstat (limited to 'api/logic')
-rw-r--r-- | api/logic/minecraft/legacy/LegacyInstance.cpp | 20 | ||||
-rw-r--r-- | api/logic/minecraft/legacy/LegacyInstance.h | 3 | ||||
-rw-r--r-- | api/logic/minecraft/legacy/LegacyUpgradeTask.cpp | 6 |
3 files changed, 26 insertions, 3 deletions
diff --git a/api/logic/minecraft/legacy/LegacyInstance.cpp b/api/logic/minecraft/legacy/LegacyInstance.cpp index 6e318458..5338763c 100644 --- a/api/logic/minecraft/legacy/LegacyInstance.cpp +++ b/api/logic/minecraft/legacy/LegacyInstance.cpp @@ -44,6 +44,26 @@ LegacyInstance::LegacyInstance(SettingsObjectPtr globalSettings, SettingsObjectP settings->registerSetting("CustomBaseJar", ""); } +QString LegacyInstance::mainJarToPreserve() const +{ + bool customJar = m_settings->get("UseCustomBaseJar").toBool(); + if(customJar) + { + auto base = baseJar(); + if(QFile::exists(base)) + { + return base; + } + } + auto runnable = runnableJar(); + if(QFile::exists(runnable)) + { + return runnable; + } + return QString(); +} + + QString LegacyInstance::baseJar() const { bool customJar = m_settings->get("UseCustomBaseJar").toBool(); diff --git a/api/logic/minecraft/legacy/LegacyInstance.h b/api/logic/minecraft/legacy/LegacyInstance.h index 4a8bc436..7ab89509 100644 --- a/api/logic/minecraft/legacy/LegacyInstance.h +++ b/api/logic/minecraft/legacy/LegacyInstance.h @@ -64,6 +64,9 @@ public: /// the default custom base jar of this instance QString defaultCustomBaseJar() const; + // the main jar that we actually want to keep when migrating the instance + QString mainJarToPreserve() const; + /*! * Whether or not custom base jar is used */ diff --git a/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp b/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp index 6cda3e4d..9fc6d92b 100644 --- a/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp +++ b/api/logic/minecraft/legacy/LegacyUpgradeTask.cpp @@ -92,10 +92,10 @@ void LegacyUpgradeTask::copyFinished() components->buildingFromScratch(); components->setComponentVersion("net.minecraft", preferredVersionNumber, true); - if(legacyInst->shouldUseCustomBaseJar()) + QString jarPath = legacyInst->mainJarToPreserve(); + if(!jarPath.isNull()) { - QString jarPath = legacyInst->customBaseJar(); - qDebug() << "Base jar is custom! : " << jarPath; + qDebug() << "Preserving base jar! : " << jarPath; // FIXME: handle case when the jar is unreadable? // TODO: check the hash, if it's the same as the upstream jar, do not do this components->installCustomJar(jarPath); |