diff options
author | Petr Mrázek <peterix@gmail.com> | 2016-06-13 22:00:09 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2016-06-13 22:00:09 +0200 |
commit | 6ecfe8546f5c2fbb543bd3a56e58f3b09485b651 (patch) | |
tree | 1e8504fbf89960fa929b5ee27b0d968347774cf6 | |
parent | 8b74f6dcf0f43d114473858ab85f806258d074a3 (diff) | |
download | MultiMC-6ecfe8546f5c2fbb543bd3a56e58f3b09485b651.tar MultiMC-6ecfe8546f5c2fbb543bd3a56e58f3b09485b651.tar.gz MultiMC-6ecfe8546f5c2fbb543bd3a56e58f3b09485b651.tar.lz MultiMC-6ecfe8546f5c2fbb543bd3a56e58f3b09485b651.tar.xz MultiMC-6ecfe8546f5c2fbb543bd3a56e58f3b09485b651.zip |
NOISSUE implement support for liteloader snapshots
-rw-r--r-- | api/logic/minecraft/liteloader/LiteLoaderVersionList.cpp | 126 | ||||
-rw-r--r-- | api/logic/minecraft/liteloader/LiteLoaderVersionList.h | 18 |
2 files changed, 99 insertions, 45 deletions
diff --git a/api/logic/minecraft/liteloader/LiteLoaderVersionList.cpp b/api/logic/minecraft/liteloader/LiteLoaderVersionList.cpp index f8bf095f..760f357a 100644 --- a/api/logic/minecraft/liteloader/LiteLoaderVersionList.cpp +++ b/api/logic/minecraft/liteloader/LiteLoaderVersionList.cpp @@ -62,6 +62,20 @@ static bool cmpVersions(BaseVersionPtr first, BaseVersionPtr second) return left->timestamp > right->timestamp; } +VersionFilePtr LiteLoaderVersion::getVersionFile() +{ + auto f = std::make_shared<VersionFile>(); + f->mainClass = "net.minecraft.launchwrapper.Launch"; + f->addTweakers += tweakClass; + f->order = 10; + f->libraries = libraries; + f->name = "LiteLoader"; + f->fileId = "com.mumfrey.liteloader"; + f->version = version; + f->minecraftVersion = mcVersion; + return f; +} + void LiteLoaderVersionList::sortVersions() { beginResetModel(); @@ -212,34 +226,91 @@ void LLListLoadTask::listDownloaded() for (auto vIt = versions.begin(); vIt != versions.end(); ++vIt) { const QString mcVersion = vIt.key(); - QString latest; - const QJsonObject artefacts = vIt.value() - .toObject() - .value("artefacts") - .toObject() - .value("com.mumfrey:liteloader") - .toObject(); - QList<BaseVersionPtr> perMcVersionList; - for (auto aIt = artefacts.begin(); aIt != artefacts.end(); ++aIt) + const QJsonObject versionObject = vIt.value().toObject(); + + auto processArtefacts = [&](QJsonObject artefacts, bool notSnapshots) { - const QString identifier = aIt.key(); - const QJsonObject artefact = aIt.value().toObject(); - if (identifier == "latest") + QString latest; + QList<BaseVersionPtr> perMcVersionList; + for (auto aIt = artefacts.begin(); aIt != artefacts.end(); ++aIt) + { + const QString identifier = aIt.key(); + const QJsonObject artefact = aIt.value().toObject(); + if (identifier == "latest") + { + latest = artefact.value("version").toString(); + continue; + } + LiteLoaderVersionPtr version(new LiteLoaderVersion()); + version->version = artefact.value("version").toString(); + version->mcVersion = mcVersion; + version->md5 = artefact.value("md5").toString(); + version->timestamp = artefact.value("timestamp").toString().toInt(); + version->tweakClass = artefact.value("tweakClass").toString(); + version->authors = authors; + version->description = description; + version->defaultUrl = defaultUrl; + const QJsonArray libs = artefact.value("libraries").toArray(); + for (auto lIt = libs.begin(); lIt != libs.end(); ++lIt) + { + auto libobject = (*lIt).toObject(); + try + { + auto lib = OneSixVersionFormat::libraryFromJson(libobject, "versions.json"); + // hack to make liteloader 1.7.10_00 work + if(lib->rawName() == GradleSpecifier("org.ow2.asm:asm-all:5.0.3")) + { + lib->setRepositoryURL("http://repo.maven.apache.org/maven2/"); + } + version->libraries.append(lib); + } + catch (Exception &e) + { + qCritical() << "Couldn't read JSON object:"; + continue; // FIXME: ignores bad libraries and continues loading + } + } + auto liteloaderLib = std::make_shared<Library>("com.mumfrey:liteloader:" + version->version); + liteloaderLib->setRepositoryURL("http://dl.liteloader.com/versions/"); + if(!notSnapshots) + { + liteloaderLib->setHint("always-stale"); + } + version->libraries.append(liteloaderLib); + perMcVersionList.append(version); + } + if(notSnapshots) { - latest = artefact.value("version").toString(); - continue; + for (auto version : perMcVersionList) + { + auto v = std::dynamic_pointer_cast<LiteLoaderVersion>(version); + v->isLatest = v->version == latest; + } } + tempList.append(perMcVersionList); + }; + + // are there actually released versions for this mc version? + if(versionObject.contains("artefacts")) + { + const QJsonObject artefacts = versionObject.value("artefacts").toObject().value("com.mumfrey:liteloader").toObject(); + processArtefacts(artefacts, true); + } + if(versionObject.contains("snapshots")) + { + QJsonObject artefacts = versionObject.value("snapshots").toObject().value("com.mumfrey:liteloader").toObject(); + processArtefacts(artefacts, false); + /* LiteLoaderVersionPtr version(new LiteLoaderVersion()); - version->version = artefact.value("version").toString(); - version->file = artefact.value("file").toString(); + version->version = mcVersion + "-SNAPSHOT"; version->mcVersion = mcVersion; - version->md5 = artefact.value("md5").toString(); - version->timestamp = artefact.value("timestamp").toString().toInt(); - version->tweakClass = artefact.value("tweakClass").toString(); + version->md5 = QString(); // FIXME: not available, unable to check + version->timestamp = QDateTime::currentMSecsSinceEpoch() / 1000LL; + version->tweakClass = "com.mumfrey.liteloader.launch.LiteLoaderTweaker"; // FIXME: guessing here, no data available version->authors = authors; version->description = description; version->defaultUrl = defaultUrl; - const QJsonArray libs = artefact.value("libraries").toArray(); + const QJsonArray libs = snapshots.value("libraries").toArray(); for (auto lIt = libs.begin(); lIt != libs.end(); ++lIt) { auto libobject = (*lIt).toObject(); @@ -256,17 +327,16 @@ void LLListLoadTask::listDownloaded() catch (Exception &e) { qCritical() << "Couldn't read JSON object:"; - continue; + continue; // FIXME: ignores bad libraries and continues loading } } - perMcVersionList.append(version); - } - for (auto version : perMcVersionList) - { - auto v = std::dynamic_pointer_cast<LiteLoaderVersion>(version); - v->isLatest = v->version == latest; + auto liteloaderLib = std::make_shared<Library>("com.mumfrey:liteloader:" + version->version); + liteloaderLib->setHint("always-stale"); + liteloaderLib->setRepositoryURL("http://dl.liteloader.com/versions/"); + version->libraries.append(liteloaderLib); + tempList.append(version); + */ } - tempList.append(perMcVersionList); } m_list->updateListData(tempList); diff --git a/api/logic/minecraft/liteloader/LiteLoaderVersionList.h b/api/logic/minecraft/liteloader/LiteLoaderVersionList.h index b85b9f0c..fcbc4236 100644 --- a/api/logic/minecraft/liteloader/LiteLoaderVersionList.h +++ b/api/logic/minecraft/liteloader/LiteLoaderVersionList.h @@ -50,26 +50,10 @@ public: { return version; } - VersionFilePtr getVersionFile() - { - auto f = std::make_shared<VersionFile>(); - f->mainClass = "net.minecraft.launchwrapper.Launch"; - f->addTweakers += tweakClass; - f->order = 10; - f->libraries = libraries; - auto liteloaderLib = std::make_shared<Library>("com.mumfrey:liteloader:" + version); - liteloaderLib->setAbsoluteUrl(QString("http://dl.liteloader.com/versions/com/mumfrey/liteloader/%1/%2").arg(mcVersion, file)); - f->libraries.append(liteloaderLib); - f->name = "LiteLoader"; - f->fileId = "com.mumfrey.liteloader"; - f->version = version; - f->minecraftVersion = mcVersion; - return f; - } + VersionFilePtr getVersionFile(); // important info QString version; - QString file; QString mcVersion; QString md5; int timestamp; |