NOISSUE implement support for liteloader snapshots

This commit is contained in:
Petr Mrázek 2016-06-13 22:00:09 +02:00
parent 8b74f6dcf0
commit 6ecfe8546f
2 changed files with 99 additions and 45 deletions

View File

@ -62,6 +62,20 @@ static bool cmpVersions(BaseVersionPtr first, BaseVersionPtr second)
return left->timestamp > right->timestamp; 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() void LiteLoaderVersionList::sortVersions()
{ {
beginResetModel(); beginResetModel();
@ -212,34 +226,91 @@ void LLListLoadTask::listDownloaded()
for (auto vIt = versions.begin(); vIt != versions.end(); ++vIt) for (auto vIt = versions.begin(); vIt != versions.end(); ++vIt)
{ {
const QString mcVersion = vIt.key(); const QString mcVersion = vIt.key();
QString latest; const QJsonObject versionObject = vIt.value().toObject();
const QJsonObject artefacts = vIt.value()
.toObject() auto processArtefacts = [&](QJsonObject artefacts, bool notSnapshots)
.value("artefacts")
.toObject()
.value("com.mumfrey:liteloader")
.toObject();
QList<BaseVersionPtr> perMcVersionList;
for (auto aIt = artefacts.begin(); aIt != artefacts.end(); ++aIt)
{ {
const QString identifier = aIt.key(); QString latest;
const QJsonObject artefact = aIt.value().toObject(); QList<BaseVersionPtr> perMcVersionList;
if (identifier == "latest") for (auto aIt = artefacts.begin(); aIt != artefacts.end(); ++aIt)
{ {
latest = artefact.value("version").toString(); const QString identifier = aIt.key();
continue; 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)
{
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()); LiteLoaderVersionPtr version(new LiteLoaderVersion());
version->version = artefact.value("version").toString(); version->version = mcVersion + "-SNAPSHOT";
version->file = artefact.value("file").toString();
version->mcVersion = mcVersion; version->mcVersion = mcVersion;
version->md5 = artefact.value("md5").toString(); version->md5 = QString(); // FIXME: not available, unable to check
version->timestamp = artefact.value("timestamp").toString().toInt(); version->timestamp = QDateTime::currentMSecsSinceEpoch() / 1000LL;
version->tweakClass = artefact.value("tweakClass").toString(); version->tweakClass = "com.mumfrey.liteloader.launch.LiteLoaderTweaker"; // FIXME: guessing here, no data available
version->authors = authors; version->authors = authors;
version->description = description; version->description = description;
version->defaultUrl = defaultUrl; 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) for (auto lIt = libs.begin(); lIt != libs.end(); ++lIt)
{ {
auto libobject = (*lIt).toObject(); auto libobject = (*lIt).toObject();
@ -256,17 +327,16 @@ void LLListLoadTask::listDownloaded()
catch (Exception &e) catch (Exception &e)
{ {
qCritical() << "Couldn't read JSON object:"; qCritical() << "Couldn't read JSON object:";
continue; continue; // FIXME: ignores bad libraries and continues loading
} }
} }
perMcVersionList.append(version); 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);
*/
} }
for (auto version : perMcVersionList)
{
auto v = std::dynamic_pointer_cast<LiteLoaderVersion>(version);
v->isLatest = v->version == latest;
}
tempList.append(perMcVersionList);
} }
m_list->updateListData(tempList); m_list->updateListData(tempList);

View File

@ -50,26 +50,10 @@ public:
{ {
return version; return version;
} }
VersionFilePtr getVersionFile() 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;
}
// important info // important info
QString version; QString version;
QString file;
QString mcVersion; QString mcVersion;
QString md5; QString md5;
int timestamp; int timestamp;