summaryrefslogtreecommitdiff
path: root/launcher/minecraft/update/LibrariesTask.cpp
diff options
context:
space:
mode:
authorMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 17:36:40 +0300
committerMehmet Samet Duman <yongdohyun@projecttick.org>2026-04-02 17:36:40 +0300
commit1d4bf6e8b1208383021e22f61d859e9b721c482d (patch)
tree21c8e0c4350d7c44d817243ebf409be625ea4f21 /launcher/minecraft/update/LibrariesTask.cpp
parent38c57e163abad6216f7e0f44d401c362c5fd5da6 (diff)
downloadProject-Tick-1d4bf6e8b1208383021e22f61d859e9b721c482d.tar.gz
Project-Tick-1d4bf6e8b1208383021e22f61d859e9b721c482d.zip
NOISSUE reformat MeshMC to new clang format rules and fixed macOS portability issue and java find issue
Signed-off-by: Mehmet Samet Duman <yongdohyun@projecttick.org>
Diffstat (limited to 'launcher/minecraft/update/LibrariesTask.cpp')
-rw-r--r--launcher/minecraft/update/LibrariesTask.cpp143
1 files changed, 76 insertions, 67 deletions
diff --git a/launcher/minecraft/update/LibrariesTask.cpp b/launcher/minecraft/update/LibrariesTask.cpp
index 0c0d3d35cc..0b0524f4e3 100644
--- a/launcher/minecraft/update/LibrariesTask.cpp
+++ b/launcher/minecraft/update/LibrariesTask.cpp
@@ -26,88 +26,97 @@
#include "Application.h"
-LibrariesTask::LibrariesTask(MinecraftInstance * inst)
+LibrariesTask::LibrariesTask(MinecraftInstance* inst)
{
- m_inst = inst;
+ m_inst = inst;
}
void LibrariesTask::executeTask()
{
- setStatus(tr("Getting the library files from Mojang..."));
- qDebug() << m_inst->name() << ": downloading libraries";
- MinecraftInstance *inst = (MinecraftInstance *)m_inst;
-
- // Build a list of URLs that will need to be downloaded.
- auto components = inst->getPackProfile();
- auto profile = components->getProfile();
-
- auto job = new NetJob(tr("Libraries for instance %1").arg(inst->name()), APPLICATION->network());
- downloadJob.reset(job);
-
- auto metacache = APPLICATION->metacache();
-
- auto processArtifactPool = [&](const QList<LibraryPtr> & pool, QStringList & errors, const QString & localPath)
- {
- for (auto lib : pool)
- {
- if(!lib)
- {
- emitFailed(tr("Null jar is specified in the metadata, aborting."));
- return false;
- }
- auto dls = lib->getDownloads(currentSystem, metacache.get(), errors, localPath);
- for(auto dl : dls)
- {
- downloadJob->addNetAction(dl);
- }
- }
- return true;
- };
-
- QStringList failedLocalLibraries;
- QList<LibraryPtr> libArtifactPool;
- libArtifactPool.append(profile->getLibraries());
- libArtifactPool.append(profile->getNativeLibraries());
- libArtifactPool.append(profile->getMavenFiles());
- libArtifactPool.append(profile->getMainJar());
- processArtifactPool(libArtifactPool, failedLocalLibraries, inst->getLocalLibraryPath());
-
- QStringList failedLocalJarMods;
- processArtifactPool(profile->getJarMods(), failedLocalJarMods, inst->jarModsDir());
-
- if (!failedLocalJarMods.empty() || !failedLocalLibraries.empty())
- {
- downloadJob.reset();
- QString failed_all = (failedLocalLibraries + failedLocalJarMods).join("\n");
- emitFailed(tr("Some artifacts marked as 'local' are missing their files:\n%1\n\nYou need to either add the files, or removed the packages that require them.\nYou'll have to correct this problem manually.").arg(failed_all));
- return;
- }
-
- connect(downloadJob.get(), &NetJob::succeeded, this, &LibrariesTask::emitSucceeded);
- connect(downloadJob.get(), &NetJob::failed, this, &LibrariesTask::jarlibFailed);
- connect(downloadJob.get(), &NetJob::progress, this, &LibrariesTask::progress);
- downloadJob->start();
+ setStatus(tr("Getting the library files from Mojang..."));
+ qDebug() << m_inst->name() << ": downloading libraries";
+ MinecraftInstance* inst = (MinecraftInstance*)m_inst;
+
+ // Build a list of URLs that will need to be downloaded.
+ auto components = inst->getPackProfile();
+ auto profile = components->getProfile();
+
+ auto job = new NetJob(tr("Libraries for instance %1").arg(inst->name()),
+ APPLICATION->network());
+ downloadJob.reset(job);
+
+ auto metacache = APPLICATION->metacache();
+
+ auto processArtifactPool = [&](const QList<LibraryPtr>& pool,
+ QStringList& errors,
+ const QString& localPath) {
+ for (auto lib : pool) {
+ if (!lib) {
+ emitFailed(
+ tr("Null jar is specified in the metadata, aborting."));
+ return false;
+ }
+ auto dls = lib->getDownloads(currentSystem, metacache.get(), errors,
+ localPath);
+ for (auto dl : dls) {
+ downloadJob->addNetAction(dl);
+ }
+ }
+ return true;
+ };
+
+ QStringList failedLocalLibraries;
+ QList<LibraryPtr> libArtifactPool;
+ libArtifactPool.append(profile->getLibraries());
+ libArtifactPool.append(profile->getNativeLibraries());
+ libArtifactPool.append(profile->getMavenFiles());
+ libArtifactPool.append(profile->getMainJar());
+ processArtifactPool(libArtifactPool, failedLocalLibraries,
+ inst->getLocalLibraryPath());
+
+ QStringList failedLocalJarMods;
+ processArtifactPool(profile->getJarMods(), failedLocalJarMods,
+ inst->jarModsDir());
+
+ if (!failedLocalJarMods.empty() || !failedLocalLibraries.empty()) {
+ downloadJob.reset();
+ QString failed_all =
+ (failedLocalLibraries + failedLocalJarMods).join("\n");
+ emitFailed(tr("Some artifacts marked as 'local' are missing their "
+ "files:\n%1\n\nYou need to either add the files, or "
+ "removed the packages that require them.\nYou'll have to "
+ "correct this problem manually.")
+ .arg(failed_all));
+ return;
+ }
+
+ connect(downloadJob.get(), &NetJob::succeeded, this,
+ &LibrariesTask::emitSucceeded);
+ connect(downloadJob.get(), &NetJob::failed, this,
+ &LibrariesTask::jarlibFailed);
+ connect(downloadJob.get(), &NetJob::progress, this,
+ &LibrariesTask::progress);
+ downloadJob->start();
}
bool LibrariesTask::canAbort() const
{
- return true;
+ return true;
}
void LibrariesTask::jarlibFailed(QString reason)
{
- emitFailed(tr("Game update failed: it was impossible to fetch the required libraries.\nReason:\n%1").arg(reason));
+ emitFailed(tr("Game update failed: it was impossible to fetch the required "
+ "libraries.\nReason:\n%1")
+ .arg(reason));
}
bool LibrariesTask::abort()
{
- if(downloadJob)
- {
- return downloadJob->abort();
- }
- else
- {
- qWarning() << "Prematurely aborted LibrariesTask";
- }
- return true;
+ if (downloadJob) {
+ return downloadJob->abort();
+ } else {
+ qWarning() << "Prematurely aborted LibrariesTask";
+ }
+ return true;
}