2022-03-24 15:00:23 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
/*
|
|
|
|
* PolyMC - Minecraft Launcher
|
|
|
|
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, version 3.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following copyright and
|
|
|
|
* permission notice:
|
|
|
|
*
|
|
|
|
* Copyright 2013-2021 MultiMC Contributors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2016-02-27 21:02:56 +00:00
|
|
|
#include "MojangVersionFormat.h"
|
2017-07-24 07:01:37 +00:00
|
|
|
#include "OneSixVersionFormat.h"
|
2016-03-07 21:26:44 +00:00
|
|
|
#include "MojangDownloadInfo.h"
|
2016-02-27 21:02:56 +00:00
|
|
|
|
|
|
|
#include "Json.h"
|
|
|
|
using namespace Json;
|
2016-03-01 08:47:12 +00:00
|
|
|
#include "ParseUtils.h"
|
2021-10-17 22:47:02 +00:00
|
|
|
#include <BuildConfig.h>
|
2016-02-27 21:02:56 +00:00
|
|
|
|
2016-03-26 15:56:57 +00:00
|
|
|
static const int CURRENT_MINIMUM_LAUNCHER_VERSION = 18;
|
2016-02-27 21:02:56 +00:00
|
|
|
|
2016-03-07 21:26:44 +00:00
|
|
|
static MojangAssetIndexInfo::Ptr assetIndexFromJson (const QJsonObject &obj);
|
|
|
|
static MojangDownloadInfo::Ptr downloadInfoFromJson (const QJsonObject &obj);
|
|
|
|
static MojangLibraryDownloadInfo::Ptr libDownloadInfoFromJson (const QJsonObject &libObj);
|
|
|
|
static QJsonObject assetIndexToJson (MojangAssetIndexInfo::Ptr assetidxinfo);
|
|
|
|
static QJsonObject libDownloadInfoToJson (MojangLibraryDownloadInfo::Ptr libinfo);
|
|
|
|
static QJsonObject downloadInfoToJson (MojangDownloadInfo::Ptr info);
|
|
|
|
|
|
|
|
namespace Bits
|
|
|
|
{
|
2016-02-27 21:02:56 +00:00
|
|
|
static void readString(const QJsonObject &root, const QString &key, QString &variable)
|
|
|
|
{
|
2018-07-15 12:51:05 +00:00
|
|
|
if (root.contains(key))
|
|
|
|
{
|
|
|
|
variable = requireString(root.value(key));
|
|
|
|
}
|
2016-02-27 21:02:56 +00:00
|
|
|
}
|
|
|
|
|
2016-03-07 21:26:44 +00:00
|
|
|
static void readDownloadInfo(MojangDownloadInfo::Ptr out, const QJsonObject &obj)
|
2016-03-07 01:01:28 +00:00
|
|
|
{
|
2018-07-15 12:51:05 +00:00
|
|
|
// optional, not used
|
|
|
|
readString(obj, "path", out->path);
|
|
|
|
// required!
|
|
|
|
out->sha1 = requireString(obj, "sha1");
|
|
|
|
out->url = requireString(obj, "url");
|
|
|
|
out->size = requireInteger(obj, "size");
|
2016-03-07 21:26:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void readAssetIndex(MojangAssetIndexInfo::Ptr out, const QJsonObject &obj)
|
|
|
|
{
|
2018-07-15 12:51:05 +00:00
|
|
|
out->totalSize = requireInteger(obj, "totalSize");
|
|
|
|
out->id = requireString(obj, "id");
|
|
|
|
// out->known = true;
|
2016-03-07 21:26:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MojangDownloadInfo::Ptr downloadInfoFromJson(const QJsonObject &obj)
|
|
|
|
{
|
2018-07-15 12:51:05 +00:00
|
|
|
auto out = std::make_shared<MojangDownloadInfo>();
|
|
|
|
Bits::readDownloadInfo(out, obj);
|
|
|
|
return out;
|
2016-03-07 21:26:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MojangAssetIndexInfo::Ptr assetIndexFromJson(const QJsonObject &obj)
|
|
|
|
{
|
2018-07-15 12:51:05 +00:00
|
|
|
auto out = std::make_shared<MojangAssetIndexInfo>();
|
|
|
|
Bits::readDownloadInfo(out, obj);
|
|
|
|
Bits::readAssetIndex(out, obj);
|
|
|
|
return out;
|
2016-03-07 21:26:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QJsonObject downloadInfoToJson(MojangDownloadInfo::Ptr info)
|
|
|
|
{
|
2018-07-15 12:51:05 +00:00
|
|
|
QJsonObject out;
|
|
|
|
if(!info->path.isNull())
|
|
|
|
{
|
|
|
|
out.insert("path", info->path);
|
|
|
|
}
|
|
|
|
out.insert("sha1", info->sha1);
|
|
|
|
out.insert("size", info->size);
|
|
|
|
out.insert("url", info->url);
|
|
|
|
return out;
|
2016-03-07 21:26:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MojangLibraryDownloadInfo::Ptr libDownloadInfoFromJson(const QJsonObject &libObj)
|
|
|
|
{
|
2018-07-15 12:51:05 +00:00
|
|
|
auto out = std::make_shared<MojangLibraryDownloadInfo>();
|
|
|
|
auto dlObj = requireObject(libObj.value("downloads"));
|
|
|
|
if(dlObj.contains("artifact"))
|
|
|
|
{
|
|
|
|
out->artifact = downloadInfoFromJson(requireObject(dlObj, "artifact"));
|
|
|
|
}
|
|
|
|
if(dlObj.contains("classifiers"))
|
|
|
|
{
|
|
|
|
auto classifiersObj = requireObject(dlObj, "classifiers");
|
|
|
|
for(auto iter = classifiersObj.begin(); iter != classifiersObj.end(); iter++)
|
|
|
|
{
|
|
|
|
auto classifier = iter.key();
|
|
|
|
auto classifierObj = requireObject(iter.value());
|
|
|
|
out->classifiers[classifier] = downloadInfoFromJson(classifierObj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return out;
|
2016-03-07 01:01:28 +00:00
|
|
|
}
|
|
|
|
|
2016-03-07 21:26:44 +00:00
|
|
|
QJsonObject libDownloadInfoToJson(MojangLibraryDownloadInfo::Ptr libinfo)
|
2016-03-07 01:01:28 +00:00
|
|
|
{
|
2018-07-15 12:51:05 +00:00
|
|
|
QJsonObject out;
|
|
|
|
if(libinfo->artifact)
|
|
|
|
{
|
|
|
|
out.insert("artifact", downloadInfoToJson(libinfo->artifact));
|
|
|
|
}
|
|
|
|
if(libinfo->classifiers.size())
|
|
|
|
{
|
|
|
|
QJsonObject classifiersOut;
|
|
|
|
for(auto iter = libinfo->classifiers.begin(); iter != libinfo->classifiers.end(); iter++)
|
|
|
|
{
|
|
|
|
classifiersOut.insert(iter.key(), downloadInfoToJson(iter.value()));
|
|
|
|
}
|
|
|
|
out.insert("classifiers", classifiersOut);
|
|
|
|
}
|
|
|
|
return out;
|
2016-03-07 01:01:28 +00:00
|
|
|
}
|
|
|
|
|
2016-03-07 21:26:44 +00:00
|
|
|
QJsonObject assetIndexToJson(MojangAssetIndexInfo::Ptr info)
|
|
|
|
{
|
2018-07-15 12:51:05 +00:00
|
|
|
QJsonObject out;
|
|
|
|
if(!info->path.isNull())
|
|
|
|
{
|
|
|
|
out.insert("path", info->path);
|
|
|
|
}
|
|
|
|
out.insert("sha1", info->sha1);
|
|
|
|
out.insert("size", info->size);
|
|
|
|
out.insert("url", info->url);
|
|
|
|
out.insert("totalSize", info->totalSize);
|
|
|
|
out.insert("id", info->id);
|
|
|
|
return out;
|
2016-03-07 21:26:44 +00:00
|
|
|
}
|
2016-03-07 01:01:28 +00:00
|
|
|
|
2016-03-19 02:06:32 +00:00
|
|
|
void MojangVersionFormat::readVersionProperties(const QJsonObject &in, VersionFile *out)
|
2016-02-27 21:02:56 +00:00
|
|
|
{
|
2018-07-15 12:51:05 +00:00
|
|
|
Bits::readString(in, "id", out->minecraftVersion);
|
|
|
|
Bits::readString(in, "mainClass", out->mainClass);
|
|
|
|
Bits::readString(in, "minecraftArguments", out->minecraftArguments);
|
|
|
|
if(out->minecraftArguments.isEmpty())
|
|
|
|
{
|
|
|
|
QString processArguments;
|
|
|
|
Bits::readString(in, "processArguments", processArguments);
|
|
|
|
QString toCompare = processArguments.toLower();
|
|
|
|
if (toCompare == "legacy")
|
|
|
|
{
|
|
|
|
out->minecraftArguments = " ${auth_player_name} ${auth_session}";
|
|
|
|
}
|
|
|
|
else if (toCompare == "username_session")
|
|
|
|
{
|
|
|
|
out->minecraftArguments = "--username ${auth_player_name} --session ${auth_session}";
|
|
|
|
}
|
|
|
|
else if (toCompare == "username_session_version")
|
|
|
|
{
|
|
|
|
out->minecraftArguments = "--username ${auth_player_name} --session ${auth_session} --version ${profile_name}";
|
|
|
|
}
|
|
|
|
else if (!toCompare.isEmpty())
|
|
|
|
{
|
|
|
|
out->addProblem(ProblemSeverity::Error, QObject::tr("processArguments is set to unknown value '%1'").arg(processArguments));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Bits::readString(in, "type", out->type);
|
2016-02-27 21:02:56 +00:00
|
|
|
|
2018-07-15 12:51:05 +00:00
|
|
|
Bits::readString(in, "assets", out->assets);
|
|
|
|
if(in.contains("assetIndex"))
|
|
|
|
{
|
|
|
|
out->mojangAssetIndex = assetIndexFromJson(requireObject(in, "assetIndex"));
|
|
|
|
}
|
|
|
|
else if (!out->assets.isNull())
|
|
|
|
{
|
|
|
|
out->mojangAssetIndex = std::make_shared<MojangAssetIndexInfo>(out->assets);
|
|
|
|
}
|
2016-02-27 21:02:56 +00:00
|
|
|
|
2018-07-15 12:51:05 +00:00
|
|
|
out->releaseTime = timeFromS3Time(in.value("releaseTime").toString(""));
|
|
|
|
out->updateTime = timeFromS3Time(in.value("time").toString(""));
|
2016-03-01 08:47:12 +00:00
|
|
|
|
2018-07-15 12:51:05 +00:00
|
|
|
if (in.contains("minimumLauncherVersion"))
|
|
|
|
{
|
|
|
|
out->minimumLauncherVersion = requireInteger(in.value("minimumLauncherVersion"));
|
|
|
|
if (out->minimumLauncherVersion > CURRENT_MINIMUM_LAUNCHER_VERSION)
|
|
|
|
{
|
|
|
|
out->addProblem(
|
|
|
|
ProblemSeverity::Warning,
|
2021-10-17 22:47:02 +00:00
|
|
|
QObject::tr("The 'minimumLauncherVersion' value of this version (%1) is higher than supported by %3 (%2). It might not work properly!")
|
2018-07-15 12:51:05 +00:00
|
|
|
.arg(out->minimumLauncherVersion)
|
2021-10-17 22:47:02 +00:00
|
|
|
.arg(CURRENT_MINIMUM_LAUNCHER_VERSION)
|
|
|
|
.arg(BuildConfig.LAUNCHER_NAME)
|
|
|
|
);
|
2018-07-15 12:51:05 +00:00
|
|
|
}
|
|
|
|
}
|
2022-03-24 13:47:22 +00:00
|
|
|
|
|
|
|
if (in.contains("compatibleJavaMajors"))
|
|
|
|
{
|
|
|
|
for (auto compatible : requireArray(in.value("compatibleJavaMajors")))
|
|
|
|
{
|
|
|
|
out->compatibleJavaMajors.append(requireInteger(compatible));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-15 12:51:05 +00:00
|
|
|
if(in.contains("downloads"))
|
|
|
|
{
|
|
|
|
auto downloadsObj = requireObject(in, "downloads");
|
|
|
|
for(auto iter = downloadsObj.begin(); iter != downloadsObj.end(); iter++)
|
|
|
|
{
|
|
|
|
auto classifier = iter.key();
|
|
|
|
auto classifierObj = requireObject(iter.value());
|
|
|
|
out->mojangDownloads[classifier] = downloadInfoFromJson(classifierObj);
|
|
|
|
}
|
|
|
|
}
|
2016-02-27 21:02:56 +00:00
|
|
|
}
|
2016-03-01 08:47:12 +00:00
|
|
|
|
2016-03-19 02:06:32 +00:00
|
|
|
VersionFilePtr MojangVersionFormat::versionFileFromJson(const QJsonDocument &doc, const QString &filename)
|
2016-02-28 18:01:54 +00:00
|
|
|
{
|
2018-07-15 12:51:05 +00:00
|
|
|
VersionFilePtr out(new VersionFile());
|
|
|
|
if (doc.isEmpty() || doc.isNull())
|
|
|
|
{
|
|
|
|
throw JSONValidationError(filename + " is empty or null");
|
|
|
|
}
|
|
|
|
if (!doc.isObject())
|
|
|
|
{
|
|
|
|
throw JSONValidationError(filename + " is not an object");
|
|
|
|
}
|
2016-02-28 18:01:54 +00:00
|
|
|
|
2018-07-15 12:51:05 +00:00
|
|
|
QJsonObject root = doc.object();
|
2016-03-19 02:06:32 +00:00
|
|
|
|
2018-07-15 12:51:05 +00:00
|
|
|
readVersionProperties(root, out.get());
|
2016-03-19 02:06:32 +00:00
|
|
|
|
2018-07-15 12:51:05 +00:00
|
|
|
out->name = "Minecraft";
|
|
|
|
out->uid = "net.minecraft";
|
|
|
|
out->version = out->minecraftVersion;
|
|
|
|
// out->filename = filename;
|
2016-03-19 02:06:32 +00:00
|
|
|
|
|
|
|
|
2018-07-15 12:51:05 +00:00
|
|
|
if (root.contains("libraries"))
|
|
|
|
{
|
|
|
|
for (auto libVal : requireArray(root.value("libraries")))
|
|
|
|
{
|
|
|
|
auto libObj = requireObject(libVal);
|
2016-03-19 02:06:32 +00:00
|
|
|
|
2021-04-01 01:50:28 +00:00
|
|
|
auto lib = MojangVersionFormat::libraryFromJson(*out, libObj, filename);
|
2018-07-15 12:51:05 +00:00
|
|
|
out->libraries.append(lib);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return out;
|
2016-03-19 02:06:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MojangVersionFormat::writeVersionProperties(const VersionFile* in, QJsonObject& out)
|
|
|
|
{
|
2018-07-15 12:51:05 +00:00
|
|
|
writeString(out, "id", in->minecraftVersion);
|
|
|
|
writeString(out, "mainClass", in->mainClass);
|
|
|
|
writeString(out, "minecraftArguments", in->minecraftArguments);
|
|
|
|
writeString(out, "type", in->type);
|
|
|
|
if(!in->releaseTime.isNull())
|
|
|
|
{
|
|
|
|
writeString(out, "releaseTime", timeToS3Time(in->releaseTime));
|
|
|
|
}
|
|
|
|
if(!in->updateTime.isNull())
|
|
|
|
{
|
|
|
|
writeString(out, "time", timeToS3Time(in->updateTime));
|
|
|
|
}
|
|
|
|
if(in->minimumLauncherVersion != -1)
|
|
|
|
{
|
|
|
|
out.insert("minimumLauncherVersion", in->minimumLauncherVersion);
|
|
|
|
}
|
|
|
|
writeString(out, "assets", in->assets);
|
|
|
|
if(in->mojangAssetIndex && in->mojangAssetIndex->known)
|
|
|
|
{
|
|
|
|
out.insert("assetIndex", assetIndexToJson(in->mojangAssetIndex));
|
|
|
|
}
|
|
|
|
if(in->mojangDownloads.size())
|
|
|
|
{
|
|
|
|
QJsonObject downloadsOut;
|
|
|
|
for(auto iter = in->mojangDownloads.begin(); iter != in->mojangDownloads.end(); iter++)
|
|
|
|
{
|
|
|
|
downloadsOut.insert(iter.key(), downloadInfoToJson(iter.value()));
|
|
|
|
}
|
|
|
|
out.insert("downloads", downloadsOut);
|
|
|
|
}
|
2016-02-28 18:01:54 +00:00
|
|
|
}
|
|
|
|
|
2016-03-19 02:06:32 +00:00
|
|
|
QJsonDocument MojangVersionFormat::versionFileToJson(const VersionFilePtr &patch)
|
2016-02-28 18:01:54 +00:00
|
|
|
{
|
2018-07-15 12:51:05 +00:00
|
|
|
QJsonObject root;
|
|
|
|
writeVersionProperties(patch.get(), root);
|
|
|
|
if (!patch->libraries.isEmpty())
|
|
|
|
{
|
|
|
|
QJsonArray array;
|
|
|
|
for (auto value: patch->libraries)
|
|
|
|
{
|
|
|
|
array.append(MojangVersionFormat::libraryToJson(value.get()));
|
|
|
|
}
|
|
|
|
root.insert("libraries", array);
|
|
|
|
}
|
2016-02-28 18:01:54 +00:00
|
|
|
|
2018-07-15 12:51:05 +00:00
|
|
|
// write the contents to a json document.
|
|
|
|
{
|
|
|
|
QJsonDocument out;
|
|
|
|
out.setObject(root);
|
|
|
|
return out;
|
|
|
|
}
|
2016-02-28 18:01:54 +00:00
|
|
|
}
|
2016-03-07 01:01:28 +00:00
|
|
|
|
2021-04-01 01:50:28 +00:00
|
|
|
LibraryPtr MojangVersionFormat::libraryFromJson(ProblemContainer & problems, const QJsonObject &libObj, const QString &filename)
|
2016-03-07 01:01:28 +00:00
|
|
|
{
|
2018-07-15 12:51:05 +00:00
|
|
|
LibraryPtr out(new Library());
|
|
|
|
if (!libObj.contains("name"))
|
|
|
|
{
|
|
|
|
throw JSONValidationError(filename + "contains a library that doesn't have a 'name' field");
|
|
|
|
}
|
2021-04-01 01:50:28 +00:00
|
|
|
auto rawName = libObj.value("name").toString();
|
|
|
|
out->m_name = rawName;
|
|
|
|
if(!out->m_name.valid()) {
|
|
|
|
problems.addProblem(ProblemSeverity::Error, QObject::tr("Library %1 name is broken and cannot be processed.").arg(rawName));
|
|
|
|
}
|
2016-03-07 01:01:28 +00:00
|
|
|
|
2018-07-15 12:51:05 +00:00
|
|
|
Bits::readString(libObj, "url", out->m_repositoryURL);
|
|
|
|
if (libObj.contains("extract"))
|
|
|
|
{
|
|
|
|
out->m_hasExcludes = true;
|
|
|
|
auto extractObj = requireObject(libObj.value("extract"));
|
|
|
|
for (auto excludeVal : requireArray(extractObj.value("exclude")))
|
|
|
|
{
|
|
|
|
out->m_extractExcludes.append(requireString(excludeVal));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (libObj.contains("natives"))
|
|
|
|
{
|
|
|
|
QJsonObject nativesObj = requireObject(libObj.value("natives"));
|
|
|
|
for (auto it = nativesObj.begin(); it != nativesObj.end(); ++it)
|
|
|
|
{
|
|
|
|
if (!it.value().isString())
|
|
|
|
{
|
|
|
|
qWarning() << filename << "contains an invalid native (skipping)";
|
|
|
|
}
|
2022-07-11 07:01:07 +00:00
|
|
|
// FIXME: Skip unknown platforms
|
|
|
|
out->m_nativeClassifiers[it.key()] = it.value().toString();
|
2018-07-15 12:51:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (libObj.contains("rules"))
|
|
|
|
{
|
|
|
|
out->applyRules = true;
|
|
|
|
out->m_rules = rulesFromJsonV4(libObj);
|
|
|
|
}
|
|
|
|
if (libObj.contains("downloads"))
|
|
|
|
{
|
|
|
|
out->m_mojangDownloads = libDownloadInfoFromJson(libObj);
|
|
|
|
}
|
|
|
|
return out;
|
2016-03-07 01:01:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QJsonObject MojangVersionFormat::libraryToJson(Library *library)
|
|
|
|
{
|
2018-07-15 12:51:05 +00:00
|
|
|
QJsonObject libRoot;
|
2021-04-01 01:50:28 +00:00
|
|
|
libRoot.insert("name", library->m_name.serialize());
|
2018-07-15 12:51:05 +00:00
|
|
|
if (!library->m_repositoryURL.isEmpty())
|
|
|
|
{
|
|
|
|
libRoot.insert("url", library->m_repositoryURL);
|
|
|
|
}
|
|
|
|
if (library->isNative())
|
|
|
|
{
|
|
|
|
QJsonObject nativeList;
|
|
|
|
auto iter = library->m_nativeClassifiers.begin();
|
|
|
|
while (iter != library->m_nativeClassifiers.end())
|
|
|
|
{
|
2022-07-11 07:01:07 +00:00
|
|
|
nativeList.insert(iter.key(), iter.value());
|
2018-07-15 12:51:05 +00:00
|
|
|
iter++;
|
|
|
|
}
|
|
|
|
libRoot.insert("natives", nativeList);
|
|
|
|
if (library->m_extractExcludes.size())
|
|
|
|
{
|
|
|
|
QJsonArray excludes;
|
|
|
|
QJsonObject extract;
|
|
|
|
for (auto exclude : library->m_extractExcludes)
|
|
|
|
{
|
|
|
|
excludes.append(exclude);
|
|
|
|
}
|
|
|
|
extract.insert("exclude", excludes);
|
|
|
|
libRoot.insert("extract", extract);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (library->m_rules.size())
|
|
|
|
{
|
|
|
|
QJsonArray allRules;
|
|
|
|
for (auto &rule : library->m_rules)
|
|
|
|
{
|
|
|
|
QJsonObject ruleObj = rule->toJson();
|
|
|
|
allRules.append(ruleObj);
|
|
|
|
}
|
|
|
|
libRoot.insert("rules", allRules);
|
|
|
|
}
|
|
|
|
if(library->m_mojangDownloads)
|
|
|
|
{
|
|
|
|
auto downloadsObj = libDownloadInfoToJson(library->m_mojangDownloads);
|
|
|
|
libRoot.insert("downloads", downloadsObj);
|
|
|
|
}
|
|
|
|
return libRoot;
|
2016-03-07 01:01:28 +00:00
|
|
|
}
|