NOISSUE refactor liteloader version file creation
It no longer implements yet another version file format serialization
This commit is contained in:
parent
a1abbd9e05
commit
54e5a98da0
@ -41,34 +41,6 @@ bool LiteLoaderInstaller::add(OneSixInstance *to)
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject obj;
|
|
||||||
|
|
||||||
obj.insert("mainClass", QString("net.minecraft.launchwrapper.Launch"));
|
|
||||||
obj.insert("+tweakers", QJsonArray::fromStringList(QStringList() << m_version->tweakClass));
|
|
||||||
obj.insert("order", 10);
|
|
||||||
|
|
||||||
QJsonArray libraries;
|
|
||||||
|
|
||||||
for (auto Library : m_version->libraries)
|
|
||||||
{
|
|
||||||
libraries.append(OneSixVersionFormat::libraryToJson(Library.get()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// liteloader
|
|
||||||
{
|
|
||||||
Library liteloaderLib("com.mumfrey:liteloader:" + m_version->version);
|
|
||||||
liteloaderLib.setAbsoluteUrl(QString("http://dl.liteloader.com/versions/com/mumfrey/liteloader/%1/%2").arg(m_version->mcVersion, m_version->file));
|
|
||||||
QJsonObject llLibObj = OneSixVersionFormat::libraryToJson(&liteloaderLib);
|
|
||||||
libraries.append(llLibObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
obj.insert("+libraries", libraries);
|
|
||||||
obj.insert("name", QString("LiteLoader"));
|
|
||||||
obj.insert("fileId", id());
|
|
||||||
obj.insert("version", m_version->version);
|
|
||||||
obj.insert("mcVersion", to->intendedVersionId());
|
|
||||||
|
|
||||||
QFile file(filename(to->instanceRoot()));
|
QFile file(filename(to->instanceRoot()));
|
||||||
if (!file.open(QFile::WriteOnly))
|
if (!file.open(QFile::WriteOnly))
|
||||||
{
|
{
|
||||||
@ -76,7 +48,7 @@ bool LiteLoaderInstaller::add(OneSixInstance *to)
|
|||||||
<< "for reading:" << file.errorString();
|
<< "for reading:" << file.errorString();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
file.write(QJsonDocument(obj).toJson());
|
file.write(OneSixVersionFormat::versionFileToJson(m_version->getVersionFile(), true).toJson());
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -86,8 +58,7 @@ class LiteLoaderInstallTask : public Task
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
LiteLoaderInstallTask(LiteLoaderInstaller *installer, OneSixInstance *instance,
|
LiteLoaderInstallTask(LiteLoaderInstaller *installer, OneSixInstance *instance, BaseVersionPtr version, QObject *parent)
|
||||||
BaseVersionPtr version, QObject *parent)
|
|
||||||
: Task(parent), m_installer(installer), m_instance(instance), m_version(version)
|
: Task(parent), m_installer(installer), m_instance(instance), m_version(version)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -95,8 +66,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void executeTask() override
|
void executeTask() override
|
||||||
{
|
{
|
||||||
LiteLoaderVersionPtr liteloaderVersion =
|
LiteLoaderVersionPtr liteloaderVersion = std::dynamic_pointer_cast<LiteLoaderVersion>(m_version);
|
||||||
std::dynamic_pointer_cast<LiteLoaderVersion>(m_version);
|
|
||||||
if (!liteloaderVersion)
|
if (!liteloaderVersion)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -104,25 +74,21 @@ protected:
|
|||||||
m_installer->prepare(liteloaderVersion);
|
m_installer->prepare(liteloaderVersion);
|
||||||
if (!m_installer->add(m_instance))
|
if (!m_installer->add(m_instance))
|
||||||
{
|
{
|
||||||
emitFailed(tr("For reasons unknown, the LiteLoader installation failed. Check your "
|
emitFailed(tr("For reasons unknown, the LiteLoader installation failed. Check your MultiMC log files for details."));
|
||||||
"MultiMC log files for details."));
|
return;
|
||||||
}
|
}
|
||||||
else
|
try
|
||||||
{
|
{
|
||||||
try
|
m_instance->reloadProfile();
|
||||||
{
|
emitSucceeded();
|
||||||
m_instance->reloadProfile();
|
}
|
||||||
emitSucceeded();
|
catch (Exception &e)
|
||||||
}
|
{
|
||||||
catch (Exception &e)
|
emitFailed(e.cause());
|
||||||
{
|
}
|
||||||
emitFailed(e.cause());
|
catch (...)
|
||||||
}
|
{
|
||||||
catch (...)
|
emitFailed(tr("Failed to load the version description file for reasons unknown."));
|
||||||
{
|
|
||||||
emitFailed(
|
|
||||||
tr("Failed to load the version description file for reasons unknown."));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,9 +98,7 @@ private:
|
|||||||
BaseVersionPtr m_version;
|
BaseVersionPtr m_version;
|
||||||
};
|
};
|
||||||
|
|
||||||
Task *LiteLoaderInstaller::createInstallTask(OneSixInstance *instance,
|
Task *LiteLoaderInstaller::createInstallTask(OneSixInstance *instance, BaseVersionPtr version, QObject *parent)
|
||||||
BaseVersionPtr version,
|
|
||||||
QObject *parent)
|
|
||||||
{
|
{
|
||||||
return new LiteLoaderInstallTask(this, instance, version, parent);
|
return new LiteLoaderInstallTask(this, instance, version, parent);
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "tasks/Task.h"
|
#include "tasks/Task.h"
|
||||||
#include "net/NetJob.h"
|
#include "net/NetJob.h"
|
||||||
#include <minecraft/Library.h>
|
#include <minecraft/Library.h>
|
||||||
|
#include <minecraft/VersionFile.h>
|
||||||
|
|
||||||
#include "multimc_logic_export.h"
|
#include "multimc_logic_export.h"
|
||||||
|
|
||||||
@ -49,6 +50,22 @@ public:
|
|||||||
{
|
{
|
||||||
return version;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
// important info
|
// important info
|
||||||
QString version;
|
QString version;
|
||||||
|
Loading…
Reference in New Issue
Block a user