void LegacyUpdate::fmllibsFinished() { legacyDownloadJob.reset(); if(!fmlLibsToProcess.isEmpty()) { setStatus(tr("Copying FML libraries into the instance...")); LegacyInstance *inst = (LegacyInstance *)m_inst; auto metacache = MMC->metacache(); int index = 0; for (auto &lib : fmlLibsToProcess) { progress(index, fmlLibsToProcess.size()); auto entry = metacache->resolveEntry("fmllibs", lib.name); auto path = PathCombine(inst->libDir(), lib.name); if(!ensureFilePathExists(path)) { emitFailed(tr("Failed creating FML library folder inside the instance.")); return; } if (!QFile::copy(entry->getFullPath(), PathCombine(inst->libDir(), lib.name))) { emitFailed(tr("Failed copying Forge/FML library: %1.").arg(lib.name)); return; } index++; } progress(index, fmlLibsToProcess.size()); } lwjglStart(); }
void OneSixUpdate::assetIndexStart() { setStatus(tr("Updating assets index...")); OneSixInstance *inst = (OneSixInstance *)m_inst; std::shared_ptr<OneSixVersion> version = inst->getFullVersion(); QString assetName = version->assets; QUrl indexUrl = "http://" + URLConstants::AWS_DOWNLOAD_INDEXES + assetName + ".json"; QString localPath = assetName + ".json"; auto job = new NetJob("Asset index for " + inst->name()); auto metacache = MMC->metacache(); auto entry = metacache->resolveEntry("asset_indexes", localPath); job->addNetAction(CacheDownload::make(indexUrl, entry)); jarlibDownloadJob.reset(job); connect(jarlibDownloadJob.get(), SIGNAL(succeeded()), SLOT(assetIndexFinished())); connect(jarlibDownloadJob.get(), SIGNAL(failed()), SLOT(assetIndexFailed())); connect(jarlibDownloadJob.get(), SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64))); jarlibDownloadJob->start(); }
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(); }
void OneSixUpdate::jarlibStart() { setStatus(tr("Getting the library files from Mojang...")); QLOG_INFO() << m_inst->name() << ": downloading libraries"; OneSixInstance *inst = (OneSixInstance *)m_inst; bool successful = inst->reloadFullVersion(); if (!successful) { emitFailed("Failed to load the version description file. It might be " "corrupted, missing or simply too new."); return; } // Build a list of URLs that will need to be downloaded. std::shared_ptr<OneSixVersion> version = inst->getFullVersion(); // minecraft.jar for this version { QString version_id = version->id; QString localPath = version_id + "/" + version_id + ".jar"; QString urlstr = "http://" + URLConstants::AWS_DOWNLOAD_VERSIONS + localPath; auto job = new NetJob("Libraries for instance " + inst->name()); auto metacache = MMC->metacache(); auto entry = metacache->resolveEntry("versions", localPath); job->addNetAction(CacheDownload::make(QUrl(urlstr), entry)); jarlibDownloadJob.reset(job); } auto libs = version->getActiveNativeLibs(); libs.append(version->getActiveNormalLibs()); auto metacache = MMC->metacache(); QList<ForgeXzDownloadPtr> ForgeLibs; for (auto lib : libs) { if (lib->hint() == "local") continue; QString raw_storage = lib->storagePath(); QString raw_dl = lib->downloadUrl(); auto f = [&](QString storage, QString dl) { auto entry = metacache->resolveEntry("libraries", storage); if (entry->stale) { if (lib->hint() == "forge-pack-xz") { ForgeLibs.append(ForgeXzDownload::make(storage, entry)); } else { jarlibDownloadJob->addNetAction(CacheDownload::make(dl, entry)); } } }; if (raw_storage.contains("${arch}")) { QString cooked_storage = raw_storage; QString cooked_dl = raw_dl; f(cooked_storage.replace("${arch}", "32"), cooked_dl.replace("${arch}", "32")); cooked_storage = raw_storage; cooked_dl = raw_dl; f(cooked_storage.replace("${arch}", "64"), cooked_dl.replace("${arch}", "64")); } else { f(raw_storage, raw_dl); } } // TODO: think about how to propagate this from the original json file... or IF AT ALL QString forgeMirrorList = "http://files.minecraftforge.net/mirror-brand.list"; if (!ForgeLibs.empty()) { jarlibDownloadJob->addNetAction( ForgeMirrors::make(ForgeLibs, jarlibDownloadJob, forgeMirrorList)); } connect(jarlibDownloadJob.get(), SIGNAL(succeeded()), SLOT(jarlibFinished())); connect(jarlibDownloadJob.get(), SIGNAL(failed()), SLOT(jarlibFailed())); connect(jarlibDownloadJob.get(), SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64))); jarlibDownloadJob->start(); }
void OneSixUpdate::jarlibStart() { OneSixInstance *inst = (OneSixInstance *)m_inst; bool successful = inst->reloadFullVersion(); if (!successful) { emitFailed("Failed to load the version description file (version.json). It might be " "corrupted, missing or simply too new."); return; } std::shared_ptr<OneSixVersion> version = inst->getFullVersion(); // download the right jar, save it in versions/$version/$version.jar QString urlstr("http://s3.amazonaws.com/Minecraft.Download/versions/"); urlstr += version->id + "/" + version->id + ".jar"; QString targetstr("versions/"); targetstr += version->id + "/" + version->id + ".jar"; auto job = new NetJob("Libraries for instance " + inst->name()); job->addNetAction(FileDownload::make(QUrl(urlstr), targetstr)); jarlibDownloadJob.reset(job); auto libs = version->getActiveNativeLibs(); libs.append(version->getActiveNormalLibs()); auto metacache = MMC->metacache(); QList<ForgeXzDownloadPtr> ForgeLibs; bool already_forge_xz = false; for (auto lib : libs) { if (lib->hint() == "local") continue; auto entry = metacache->resolveEntry("libraries", lib->storagePath()); if (entry->stale) { if (lib->hint() == "forge-pack-xz") { ForgeLibs.append(ForgeXzDownload::make(lib->storagePath(), entry)); } else { jarlibDownloadJob->addNetAction(CacheDownload::make(lib->downloadUrl(), entry)); } } } // TODO: think about how to propagate this from the original json file... or IF AT ALL QString forgeMirrorList = "http://files.minecraftforge.net/mirror-brand.list"; if (!ForgeLibs.empty()) { jarlibDownloadJob->addNetAction( ForgeMirrors::make(ForgeLibs, jarlibDownloadJob, forgeMirrorList)); } connect(jarlibDownloadJob.get(), SIGNAL(succeeded()), SLOT(jarlibFinished())); connect(jarlibDownloadJob.get(), SIGNAL(failed()), SLOT(jarlibFailed())); connect(jarlibDownloadJob.get(), SIGNAL(progress(qint64, qint64)), SIGNAL(progress(qint64, qint64))); jarlibDownloadJob->start(); }