void LegacyUpdate::jarStart() { LegacyInstance *inst = (LegacyInstance *)m_inst; if (!inst->shouldUpdate() || inst->shouldUseCustomBaseJar()) { ModTheJar(); return; } setStatus(tr("Checking for jar updates...")); // Make directories QDir binDir(inst->binDir()); if (!binDir.exists() && !binDir.mkpath(".")) { emitFailed("Failed to create bin folder."); return; } // Build a list of URLs that will need to be downloaded. setStatus(tr("Downloading new minecraft.jar ...")); QString version_id = inst->intendedVersionId(); QString localPath = version_id + "/" + version_id + ".jar"; QString urlstr = "http://" + URLConstants::AWS_DOWNLOAD_VERSIONS + localPath; auto dljob = new NetJob("Minecraft.jar for version " + version_id); auto metacache = MMC->metacache(); auto entry = metacache->resolveEntry("versions", localPath); dljob->addNetAction(CacheDownload::make(QUrl(urlstr), entry)); connect(dljob, SIGNAL(succeeded()), SLOT(jarFinished())); connect(dljob, SIGNAL(failed()), SLOT(jarFailed())); connect(dljob, SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64))); legacyDownloadJob.reset(dljob); legacyDownloadJob->start(); }
void LegacyUpdate::fmllibsStart() { // Get the mod list LegacyInstance *inst = (LegacyInstance *)m_inst; auto modList = inst->jarModList(); bool forge_present = false; QString version = inst->intendedVersionId(); if (!fmlLibsMapping.contains(version)) { lwjglStart(); return; } auto &libList = fmlLibsMapping[version]; // determine if we need some libs for FML or forge setStatus(tr("Checking for FML libraries...")); for (unsigned i = 0; i < modList->size(); i++) { auto &mod = modList->operator[](i); // do not use disabled mods. if (!mod.enabled()) continue; if (mod.type() != Mod::MOD_ZIPFILE) continue; if (mod.mmc_id().contains("forge", Qt::CaseInsensitive)) { forge_present = true; break; } if (mod.mmc_id().contains("fml", Qt::CaseInsensitive)) { forge_present = true; break; } } // we don't... if (!forge_present) { lwjglStart(); return; } // now check the lib folder inside the instance for files. for (auto &lib : libList) { QFileInfo libInfo(PathCombine(inst->libDir(), lib.name)); if (libInfo.exists()) continue; fmlLibsToProcess.append(lib); } // if everything is in place, there's nothing to do here... if (fmlLibsToProcess.isEmpty()) { lwjglStart(); return; } // download missing libs to our place setStatus(tr("Dowloading FML libraries...")); auto dljob = new NetJob("FML libraries"); auto metacache = MMC->metacache(); for (auto &lib : fmlLibsToProcess) { auto entry = metacache->resolveEntry("fmllibs", lib.name); QString urlString = lib.ours ? URLConstants::FMLLIBS_OUR_BASE_URL + lib.name : URLConstants::FMLLIBS_FORGE_BASE_URL + lib.name; dljob->addNetAction(CacheDownload::make(QUrl(urlString), entry)); } connect(dljob, SIGNAL(succeeded()), SLOT(fmllibsFinished())); connect(dljob, SIGNAL(failed()), SLOT(fmllibsFailed())); connect(dljob, SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64))); legacyDownloadJob.reset(dljob); legacyDownloadJob->start(); }