NOISSUE make new Mojang version format pass through MultiMC structures
Not yet used effectively, but it is read and written properly
This commit is contained in:
parent
3d8728f52f
commit
d4eacb56b3
@ -186,8 +186,8 @@ set(LOGIC_SOURCES
|
|||||||
minecraft/MinecraftVersionList.cpp
|
minecraft/MinecraftVersionList.cpp
|
||||||
minecraft/MinecraftVersionList.h
|
minecraft/MinecraftVersionList.h
|
||||||
minecraft/NullProfileStrategy.h
|
minecraft/NullProfileStrategy.h
|
||||||
minecraft/OneSixRule.cpp
|
minecraft/Rule.cpp
|
||||||
minecraft/OneSixRule.h
|
minecraft/Rule.h
|
||||||
minecraft/OpSys.cpp
|
minecraft/OpSys.cpp
|
||||||
minecraft/OpSys.h
|
minecraft/OpSys.h
|
||||||
minecraft/ParseUtils.cpp
|
minecraft/ParseUtils.cpp
|
||||||
@ -195,8 +195,9 @@ set(LOGIC_SOURCES
|
|||||||
minecraft/ProfileUtils.cpp
|
minecraft/ProfileUtils.cpp
|
||||||
minecraft/ProfileUtils.h
|
minecraft/ProfileUtils.h
|
||||||
minecraft/ProfileStrategy.h
|
minecraft/ProfileStrategy.h
|
||||||
minecraft/RawLibrary.cpp
|
minecraft/Library.cpp
|
||||||
minecraft/RawLibrary.h
|
minecraft/Library.h
|
||||||
|
minecraft/MojangDownloadInfo.h
|
||||||
minecraft/VersionBuildError.h
|
minecraft/VersionBuildError.h
|
||||||
minecraft/VersionFile.cpp
|
minecraft/VersionFile.cpp
|
||||||
minecraft/VersionFile.h
|
minecraft/VersionFile.h
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "RawLibrary.h"
|
#include "Library.h"
|
||||||
#include <FileSystem.h>
|
#include <FileSystem.h>
|
||||||
|
|
||||||
QStringList RawLibrary::files() const
|
QStringList Library::files() const
|
||||||
{
|
{
|
||||||
QStringList retval;
|
QStringList retval;
|
||||||
QString storage = storageSuffix();
|
QString storage = storageSuffix();
|
||||||
@ -19,7 +19,7 @@ QStringList RawLibrary::files() const
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RawLibrary::filesExist(const QDir &base) const
|
bool Library::filesExist(const QDir &base) const
|
||||||
{
|
{
|
||||||
auto libFiles = files();
|
auto libFiles = files();
|
||||||
for(auto file: libFiles)
|
for(auto file: libFiles)
|
||||||
@ -32,7 +32,7 @@ bool RawLibrary::filesExist(const QDir &base) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RawLibrary::url() const
|
QString Library::url() const
|
||||||
{
|
{
|
||||||
if (!m_absolute_url.isEmpty())
|
if (!m_absolute_url.isEmpty())
|
||||||
{
|
{
|
||||||
@ -54,7 +54,7 @@ QString RawLibrary::url() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RawLibrary::isActive() const
|
bool Library::isActive() const
|
||||||
{
|
{
|
||||||
bool result = true;
|
bool result = true;
|
||||||
if (m_rules.empty())
|
if (m_rules.empty())
|
||||||
@ -79,17 +79,17 @@ bool RawLibrary::isActive() const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RawLibrary::setStoragePrefix(QString prefix)
|
void Library::setStoragePrefix(QString prefix)
|
||||||
{
|
{
|
||||||
m_storagePrefix = prefix;
|
m_storagePrefix = prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RawLibrary::defaultStoragePrefix()
|
QString Library::defaultStoragePrefix()
|
||||||
{
|
{
|
||||||
return "libraries/";
|
return "libraries/";
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RawLibrary::storagePrefix() const
|
QString Library::storagePrefix() const
|
||||||
{
|
{
|
||||||
if(m_storagePrefix.isEmpty())
|
if(m_storagePrefix.isEmpty())
|
||||||
{
|
{
|
||||||
@ -98,7 +98,7 @@ QString RawLibrary::storagePrefix() const
|
|||||||
return m_storagePrefix;
|
return m_storagePrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RawLibrary::storageSuffix() const
|
QString Library::storageSuffix() const
|
||||||
{
|
{
|
||||||
// non-native? use only the gradle specifier
|
// non-native? use only the gradle specifier
|
||||||
if (!isNative())
|
if (!isNative())
|
||||||
@ -119,12 +119,12 @@ QString RawLibrary::storageSuffix() const
|
|||||||
return nativeSpec.toPath();
|
return nativeSpec.toPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString RawLibrary::storagePath() const
|
QString Library::storagePath() const
|
||||||
{
|
{
|
||||||
return FS::PathCombine(storagePrefix(), storageSuffix());
|
return FS::PathCombine(storagePrefix(), storageSuffix());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RawLibrary::storagePathIsDefault() const
|
bool Library::storagePathIsDefault() const
|
||||||
{
|
{
|
||||||
return m_storagePrefix.isEmpty();
|
return m_storagePrefix.isEmpty();
|
||||||
}
|
}
|
@ -8,30 +8,31 @@
|
|||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "OneSixRule.h"
|
#include "Rule.h"
|
||||||
#include "minecraft/OpSys.h"
|
#include "minecraft/OpSys.h"
|
||||||
#include "GradleSpecifier.h"
|
#include "GradleSpecifier.h"
|
||||||
|
#include "MojangDownloadInfo.h"
|
||||||
#include "net/URLConstants.h"
|
#include "net/URLConstants.h"
|
||||||
|
|
||||||
class RawLibrary;
|
class Library;
|
||||||
typedef std::shared_ptr<RawLibrary> RawLibraryPtr;
|
typedef std::shared_ptr<Library> LibraryPtr;
|
||||||
|
|
||||||
class RawLibrary
|
class Library
|
||||||
{
|
{
|
||||||
friend class OneSixVersionFormat;
|
friend class OneSixVersionFormat;
|
||||||
friend class MojangVersionFormat;
|
friend class MojangVersionFormat;
|
||||||
public:
|
public:
|
||||||
RawLibrary()
|
Library()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
RawLibrary(const QString &name)
|
Library(const QString &name)
|
||||||
{
|
{
|
||||||
m_name = name;
|
m_name = name;
|
||||||
}
|
}
|
||||||
/// limited copy without some data. TODO: why?
|
/// limited copy without some data. TODO: why?
|
||||||
static RawLibraryPtr limitedCopy(RawLibraryPtr base)
|
static LibraryPtr limitedCopy(LibraryPtr base)
|
||||||
{
|
{
|
||||||
auto newlib = std::make_shared<RawLibrary>();
|
auto newlib = std::make_shared<Library>();
|
||||||
newlib->m_name = base->m_name;
|
newlib->m_name = base->m_name;
|
||||||
newlib->m_base_url = base->m_base_url;
|
newlib->m_base_url = base->m_base_url;
|
||||||
newlib->m_hint = base->m_hint;
|
newlib->m_hint = base->m_hint;
|
||||||
@ -158,7 +159,6 @@ protected: /* data */
|
|||||||
/// DEPRECATED: MultiMC-specific absolute URL. takes precedence over the implicit maven repo URL, if defined
|
/// DEPRECATED: MultiMC-specific absolute URL. takes precedence over the implicit maven repo URL, if defined
|
||||||
QString m_absolute_url;
|
QString m_absolute_url;
|
||||||
|
|
||||||
public: /* data */
|
|
||||||
/**
|
/**
|
||||||
* MultiMC-specific type hint - modifies how the library is treated
|
* MultiMC-specific type hint - modifies how the library is treated
|
||||||
*/
|
*/
|
||||||
@ -166,7 +166,7 @@ public: /* data */
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* storage - by default the local libraries folder in multimc, but could be elsewhere
|
* storage - by default the local libraries folder in multimc, but could be elsewhere
|
||||||
* MultiMC specific, because of FTB.
|
* MultiMC specific, because of FTB.
|
||||||
*/
|
*/
|
||||||
QString m_storagePrefix;
|
QString m_storagePrefix;
|
||||||
|
|
||||||
@ -184,4 +184,7 @@ public: /* data */
|
|||||||
|
|
||||||
/// rules associated with the library
|
/// rules associated with the library
|
||||||
QList<std::shared_ptr<Rule>> m_rules;
|
QList<std::shared_ptr<Rule>> m_rules;
|
||||||
|
|
||||||
|
/// MOJANG: container with Mojang style download info
|
||||||
|
MojangLibraryDownloadInfoPtr m_mojang_downloads;
|
||||||
};
|
};
|
@ -230,9 +230,9 @@ bool MinecraftProfile::revertToVanilla()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<std::shared_ptr<RawLibrary> > MinecraftProfile::getActiveNormalLibs()
|
QList<std::shared_ptr<Library> > MinecraftProfile::getActiveNormalLibs()
|
||||||
{
|
{
|
||||||
QList<std::shared_ptr<RawLibrary> > output;
|
QList<std::shared_ptr<Library> > output;
|
||||||
for (auto lib : libraries)
|
for (auto lib : libraries)
|
||||||
{
|
{
|
||||||
if (lib->isActive() && !lib->isNative())
|
if (lib->isActive() && !lib->isNative())
|
||||||
@ -251,9 +251,9 @@ QList<std::shared_ptr<RawLibrary> > MinecraftProfile::getActiveNormalLibs()
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<std::shared_ptr<RawLibrary> > MinecraftProfile::getActiveNativeLibs()
|
QList<std::shared_ptr<Library> > MinecraftProfile::getActiveNativeLibs()
|
||||||
{
|
{
|
||||||
QList<std::shared_ptr<RawLibrary> > output;
|
QList<std::shared_ptr<Library> > output;
|
||||||
for (auto lib : libraries)
|
for (auto lib : libraries)
|
||||||
{
|
{
|
||||||
if (lib->isActive() && lib->isNative())
|
if (lib->isActive() && lib->isNative())
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "RawLibrary.h"
|
#include "Library.h"
|
||||||
#include "VersionFile.h"
|
#include "VersionFile.h"
|
||||||
#include "JarMod.h"
|
#include "JarMod.h"
|
||||||
|
|
||||||
@ -93,10 +93,10 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
/// get all java libraries that belong to the classpath
|
/// get all java libraries that belong to the classpath
|
||||||
QList<RawLibraryPtr> getActiveNormalLibs();
|
QList<LibraryPtr> getActiveNormalLibs();
|
||||||
|
|
||||||
/// get all native libraries that need to be available to the process
|
/// get all native libraries that need to be available to the process
|
||||||
QList<RawLibraryPtr> getActiveNativeLibs();
|
QList<LibraryPtr> getActiveNativeLibs();
|
||||||
|
|
||||||
/// get file ID of the patch file at #
|
/// get file ID of the patch file at #
|
||||||
QString versionFileId(const int index) const;
|
QString versionFileId(const int index) const;
|
||||||
@ -161,10 +161,10 @@ public: /* data */
|
|||||||
QString appletClass;
|
QString appletClass;
|
||||||
|
|
||||||
/// the list of libs - both active and inactive, native and java
|
/// the list of libs - both active and inactive, native and java
|
||||||
QList<RawLibraryPtr> libraries;
|
QList<LibraryPtr> libraries;
|
||||||
|
|
||||||
/// same, but only vanilla.
|
/// same, but only vanilla.
|
||||||
QList<RawLibraryPtr> vanillaLibraries;
|
QList<LibraryPtr> vanillaLibraries;
|
||||||
|
|
||||||
/// traits, collected from all the version files (version files can only add)
|
/// traits, collected from all the version files (version files can only add)
|
||||||
QSet<QString> traits;
|
QSet<QString> traits;
|
||||||
|
92
logic/minecraft/MojangDownloadInfo.h
Normal file
92
logic/minecraft/MojangDownloadInfo.h
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <QString>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
class MojangDownloadInfo
|
||||||
|
{
|
||||||
|
friend class MojangVersionFormat;
|
||||||
|
public:
|
||||||
|
QString getUrl()
|
||||||
|
{
|
||||||
|
return m_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString getSha1()
|
||||||
|
{
|
||||||
|
return m_sha1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getSize()
|
||||||
|
{
|
||||||
|
return m_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/// Local filesystem path. WARNING: not used, only here so we can pass through mojang files unmolested!
|
||||||
|
QString m_path;
|
||||||
|
/// absolute URL of this file
|
||||||
|
QString m_url;
|
||||||
|
/// sha-1 checksum of the file
|
||||||
|
QString m_sha1;
|
||||||
|
/// size of the file in bytes
|
||||||
|
int m_size;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::shared_ptr<MojangDownloadInfo> MojangDownloadInfoPtr;
|
||||||
|
|
||||||
|
class MojangLibraryDownloadInfo
|
||||||
|
{
|
||||||
|
friend class MojangVersionFormat;
|
||||||
|
public:
|
||||||
|
MojangDownloadInfo *getDownloadInfo(QString classifier)
|
||||||
|
{
|
||||||
|
if (classifier.isNull())
|
||||||
|
{
|
||||||
|
return artifact.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
return classifiers[classifier].get();
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
MojangDownloadInfoPtr artifact;
|
||||||
|
QMap<QString, MojangDownloadInfoPtr> classifiers;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::shared_ptr<MojangLibraryDownloadInfo> MojangLibraryDownloadInfoPtr;
|
||||||
|
|
||||||
|
class MojangAssetIndexInfo : public MojangDownloadInfo
|
||||||
|
{
|
||||||
|
friend class MojangVersionFormat;
|
||||||
|
public:
|
||||||
|
MojangAssetIndexInfo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
MojangAssetIndexInfo(QString id)
|
||||||
|
{
|
||||||
|
m_id = id;
|
||||||
|
m_url = "https://s3.amazonaws.com/Minecraft.Download/indexes/" + id + ".json";
|
||||||
|
m_known = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getTotalSize()
|
||||||
|
{
|
||||||
|
return m_totalSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString getId()
|
||||||
|
{
|
||||||
|
return m_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool sizeAndHashKnown()
|
||||||
|
{
|
||||||
|
return m_known;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int m_totalSize;
|
||||||
|
QString m_id;
|
||||||
|
bool m_known = true;
|
||||||
|
};
|
||||||
|
typedef std::shared_ptr<MojangAssetIndexInfo> MojangAssetIndexInfoPtr;
|
@ -18,6 +18,37 @@ static void readString(const QJsonObject &root, const QString &key, QString &var
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MojangAssetIndexInfoPtr MojangVersionFormat::assetIndexFromJson(const QJsonObject &obj)
|
||||||
|
{
|
||||||
|
auto out = std::make_shared<MojangAssetIndexInfo>();
|
||||||
|
// optional, not used
|
||||||
|
readString(obj, "path", out->m_path);
|
||||||
|
// required!
|
||||||
|
out->m_sha1 = requireString(obj, "sha1");
|
||||||
|
out->m_url = requireString(obj, "url");
|
||||||
|
out->m_size = requireInteger(obj, "size");
|
||||||
|
out->m_totalSize = requireInteger(obj, "totalSize");
|
||||||
|
out->m_id = requireString(obj, "id");
|
||||||
|
// out->m_known = true;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject MojangVersionFormat::assetIndexToJson(MojangAssetIndexInfoPtr info)
|
||||||
|
{
|
||||||
|
QJsonObject out;
|
||||||
|
if(!info->m_path.isNull())
|
||||||
|
{
|
||||||
|
out.insert("path", info->m_path);
|
||||||
|
}
|
||||||
|
out.insert("sha1", info->m_sha1);
|
||||||
|
out.insert("size", info->m_size);
|
||||||
|
out.insert("url", info->m_url);
|
||||||
|
out.insert("totalSize", info->m_totalSize);
|
||||||
|
out.insert("id", info->m_id);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
VersionFilePtr MojangVersionFormat::versionFileFromJson(const QJsonDocument &doc, const QString &filename)
|
VersionFilePtr MojangVersionFormat::versionFileFromJson(const QJsonDocument &doc, const QString &filename)
|
||||||
{
|
{
|
||||||
VersionFilePtr out(new VersionFile());
|
VersionFilePtr out(new VersionFile());
|
||||||
@ -43,6 +74,10 @@ VersionFilePtr MojangVersionFormat::versionFileFromJson(const QJsonDocument &doc
|
|||||||
readString(root, "minecraftArguments", out->overwriteMinecraftArguments);
|
readString(root, "minecraftArguments", out->overwriteMinecraftArguments);
|
||||||
readString(root, "type", out->type);
|
readString(root, "type", out->type);
|
||||||
|
|
||||||
|
if(root.contains("assetIndex"))
|
||||||
|
{
|
||||||
|
out->mojangAssetIndex = assetIndexFromJson(requireObject(root, "assetIndex"));
|
||||||
|
}
|
||||||
readString(root, "assets", out->assets);
|
readString(root, "assets", out->assets);
|
||||||
|
|
||||||
out->m_releaseTime = timeFromS3Time(root.value("releaseTime").toString(""));
|
out->m_releaseTime = timeFromS3Time(root.value("releaseTime").toString(""));
|
||||||
@ -67,14 +102,24 @@ VersionFilePtr MojangVersionFormat::versionFileFromJson(const QJsonDocument &doc
|
|||||||
{
|
{
|
||||||
auto libObj = requireObject(libVal);
|
auto libObj = requireObject(libVal);
|
||||||
|
|
||||||
auto lib = OneSixVersionFormat::libraryFromJson(libObj, filename);
|
auto lib = MojangVersionFormat::libraryFromJson(libObj, filename);
|
||||||
out->addLibs.append(lib);
|
out->addLibs.append(lib);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(root.contains("downloads"))
|
||||||
|
{
|
||||||
|
auto downloadsObj = requireObject(root, "downloads");
|
||||||
|
for(auto iter = downloadsObj.begin(); iter != downloadsObj.end(); iter++)
|
||||||
|
{
|
||||||
|
auto classifier = iter.key();
|
||||||
|
auto classifierObj = requireObject(iter.value());
|
||||||
|
out->mojangDownloads[classifier] = downloadInfoFromJson(classifierObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QJsonDocument versionFileToJson(VersionFilePtr patch)
|
QJsonDocument MojangVersionFormat::versionFileToJson(VersionFilePtr patch)
|
||||||
{
|
{
|
||||||
QJsonObject root;
|
QJsonObject root;
|
||||||
writeString(root, "id", patch->id);
|
writeString(root, "id", patch->id);
|
||||||
@ -95,10 +140,23 @@ static QJsonDocument versionFileToJson(VersionFilePtr patch)
|
|||||||
QJsonArray array;
|
QJsonArray array;
|
||||||
for (auto value: patch->addLibs)
|
for (auto value: patch->addLibs)
|
||||||
{
|
{
|
||||||
array.append(OneSixVersionFormat::libraryToJson(value.get()));
|
array.append(MojangVersionFormat::libraryToJson(value.get()));
|
||||||
}
|
}
|
||||||
root.insert("libraries", array);
|
root.insert("libraries", array);
|
||||||
}
|
}
|
||||||
|
if(patch->mojangAssetIndex && patch->mojangAssetIndex->sizeAndHashKnown())
|
||||||
|
{
|
||||||
|
root.insert("assetIndex", MojangVersionFormat::assetIndexToJson(patch->mojangAssetIndex));
|
||||||
|
}
|
||||||
|
if(patch->mojangDownloads.size())
|
||||||
|
{
|
||||||
|
QJsonObject downloadsOut;
|
||||||
|
for(auto iter = patch->mojangDownloads.begin(); iter != patch->mojangDownloads.end(); iter++)
|
||||||
|
{
|
||||||
|
downloadsOut.insert(iter.key(), downloadInfoToJson(iter.value()));
|
||||||
|
}
|
||||||
|
root.insert("downloads", downloadsOut);
|
||||||
|
}
|
||||||
// write the contents to a json document.
|
// write the contents to a json document.
|
||||||
{
|
{
|
||||||
QJsonDocument out;
|
QJsonDocument out;
|
||||||
@ -133,3 +191,244 @@ QJsonDocument MojangVersionFormat::profilePatchToJson(const ProfilePatchPtr &pat
|
|||||||
}
|
}
|
||||||
throw VersionIncomplete(QObject::tr("Unhandled object type while processing %1").arg(patch->getPatchName()));
|
throw VersionIncomplete(QObject::tr("Unhandled object type while processing %1").arg(patch->getPatchName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
class MojangDownloadInfo
|
||||||
|
{
|
||||||
|
friend class MojangVersionFormat;
|
||||||
|
public:
|
||||||
|
QString getUrl()
|
||||||
|
{
|
||||||
|
return m_url;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString getSha1()
|
||||||
|
{
|
||||||
|
return m_sha1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getSize()
|
||||||
|
{
|
||||||
|
return m_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QString m_url;
|
||||||
|
QString m_sha1;
|
||||||
|
int m_size;
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
MojangDownloadInfoPtr MojangVersionFormat::downloadInfoFromJson(const QJsonObject &obj)
|
||||||
|
{
|
||||||
|
auto out = std::make_shared<MojangDownloadInfo>();
|
||||||
|
// optional, not used
|
||||||
|
readString(obj, "path", out->m_path);
|
||||||
|
// required!
|
||||||
|
out->m_sha1 = requireString(obj, "sha1");
|
||||||
|
out->m_url = requireString(obj, "url");
|
||||||
|
out->m_size = requireInteger(obj, "size");
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
class MojangLibraryDownloadInfo
|
||||||
|
{
|
||||||
|
friend class MojangVersionFormat;
|
||||||
|
public:
|
||||||
|
MojangDownloadInfo getDownloadInfo(QString classifier)
|
||||||
|
{
|
||||||
|
if (classifier.isNull())
|
||||||
|
{
|
||||||
|
return artifact;
|
||||||
|
}
|
||||||
|
|
||||||
|
return classifiers[classifier];
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
MojangDownloadInfo artifact;
|
||||||
|
QMap<QString, MojangDownloadInfo> classifiers;
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
"downloads": {
|
||||||
|
"artifact": {
|
||||||
|
"path": "org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209.jar",
|
||||||
|
"sha1": "b04f3ee8f5e43fa3b162981b50bb72fe1acabb33",
|
||||||
|
"size": 22,
|
||||||
|
"url": "https://libraries.minecraft.net/org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209.jar"
|
||||||
|
},
|
||||||
|
"classifiers": {
|
||||||
|
"natives-linux": {
|
||||||
|
"path": "org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-linux.jar",
|
||||||
|
"sha1": "931074f46c795d2f7b30ed6395df5715cfd7675b",
|
||||||
|
"size": 578680,
|
||||||
|
"url": "https://libraries.minecraft.net/org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-linux.jar"
|
||||||
|
},
|
||||||
|
"natives-osx": {
|
||||||
|
"path": "org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar",
|
||||||
|
"sha1": "bcab850f8f487c3f4c4dbabde778bb82bd1a40ed",
|
||||||
|
"size": 426822,
|
||||||
|
"url": "https://libraries.minecraft.net/org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar"
|
||||||
|
},
|
||||||
|
"natives-windows": {
|
||||||
|
"path": "org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-windows.jar",
|
||||||
|
"sha1": "b84d5102b9dbfabfeb5e43c7e2828d98a7fc80e0",
|
||||||
|
"size": 613748,
|
||||||
|
"url": "https://libraries.minecraft.net/org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-windows.jar"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
MojangLibraryDownloadInfoPtr MojangVersionFormat::libDownloadInfoFromJson(const QJsonObject &libObj)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
LibraryPtr MojangVersionFormat::libraryFromJson(const QJsonObject &libObj, const QString &filename)
|
||||||
|
{
|
||||||
|
LibraryPtr out(new Library());
|
||||||
|
if (!libObj.contains("name"))
|
||||||
|
{
|
||||||
|
throw JSONValidationError(filename + "contains a library that doesn't have a 'name' field");
|
||||||
|
}
|
||||||
|
out->m_name = libObj.value("name").toString();
|
||||||
|
|
||||||
|
readString(libObj, "url", out->m_base_url);
|
||||||
|
if (libObj.contains("extract"))
|
||||||
|
{
|
||||||
|
out->applyExcludes = true;
|
||||||
|
auto extractObj = requireObject(libObj.value("extract"));
|
||||||
|
for (auto excludeVal : requireArray(extractObj.value("exclude")))
|
||||||
|
{
|
||||||
|
out->extract_excludes.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)";
|
||||||
|
}
|
||||||
|
OpSys opSys = OpSys_fromString(it.key());
|
||||||
|
if (opSys != Os_Other)
|
||||||
|
{
|
||||||
|
out->m_native_classifiers[opSys] = it.value().toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (libObj.contains("rules"))
|
||||||
|
{
|
||||||
|
out->applyRules = true;
|
||||||
|
out->m_rules = rulesFromJsonV4(libObj);
|
||||||
|
}
|
||||||
|
if (libObj.contains("downloads"))
|
||||||
|
{
|
||||||
|
out->m_mojang_downloads = libDownloadInfoFromJson(libObj);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject MojangVersionFormat::downloadInfoToJson(MojangDownloadInfoPtr info)
|
||||||
|
{
|
||||||
|
QJsonObject out;
|
||||||
|
if(!info->m_path.isNull())
|
||||||
|
{
|
||||||
|
out.insert("path", info->m_path);
|
||||||
|
}
|
||||||
|
out.insert("sha1", info->m_sha1);
|
||||||
|
out.insert("size", info->m_size);
|
||||||
|
out.insert("url", info->m_url);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject MojangVersionFormat::libDownloadInfoToJson(MojangLibraryDownloadInfoPtr libinfo)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject MojangVersionFormat::libraryToJson(Library *library)
|
||||||
|
{
|
||||||
|
QJsonObject libRoot;
|
||||||
|
libRoot.insert("name", (QString)library->m_name);
|
||||||
|
if (library->m_base_url != "http://" + URLConstants::AWS_DOWNLOAD_LIBRARIES &&
|
||||||
|
library->m_base_url != "https://" + URLConstants::AWS_DOWNLOAD_LIBRARIES &&
|
||||||
|
library->m_base_url != "https://" + URLConstants::LIBRARY_BASE && !library->m_base_url.isEmpty())
|
||||||
|
{
|
||||||
|
libRoot.insert("url", library->m_base_url);
|
||||||
|
}
|
||||||
|
if (library->isNative())
|
||||||
|
{
|
||||||
|
QJsonObject nativeList;
|
||||||
|
auto iter = library->m_native_classifiers.begin();
|
||||||
|
while (iter != library->m_native_classifiers.end())
|
||||||
|
{
|
||||||
|
nativeList.insert(OpSys_toString(iter.key()), iter.value());
|
||||||
|
iter++;
|
||||||
|
}
|
||||||
|
libRoot.insert("natives", nativeList);
|
||||||
|
if (library->extract_excludes.size())
|
||||||
|
{
|
||||||
|
QJsonArray excludes;
|
||||||
|
QJsonObject extract;
|
||||||
|
for (auto exclude : library->extract_excludes)
|
||||||
|
{
|
||||||
|
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_mojang_downloads)
|
||||||
|
{
|
||||||
|
auto downloadsObj = libDownloadInfoToJson(library->m_mojang_downloads);
|
||||||
|
libRoot.insert("downloads", downloadsObj);
|
||||||
|
}
|
||||||
|
return libRoot;
|
||||||
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <minecraft/VersionFile.h>
|
#include <minecraft/VersionFile.h>
|
||||||
|
#include <minecraft/Library.h>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
|
||||||
#include "multimc_logic_export.h"
|
#include "multimc_logic_export.h"
|
||||||
@ -11,4 +12,18 @@ public:
|
|||||||
// version files / profile patches
|
// version files / profile patches
|
||||||
static VersionFilePtr versionFileFromJson(const QJsonDocument &doc, const QString &filename);
|
static VersionFilePtr versionFileFromJson(const QJsonDocument &doc, const QString &filename);
|
||||||
static QJsonDocument profilePatchToJson(const ProfilePatchPtr &patch);
|
static QJsonDocument profilePatchToJson(const ProfilePatchPtr &patch);
|
||||||
|
|
||||||
|
// libraries
|
||||||
|
static LibraryPtr libraryFromJson(const QJsonObject &libObj, const QString &filename);
|
||||||
|
static QJsonObject libraryToJson(Library *library);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static QJsonDocument versionFileToJson(VersionFilePtr patch);
|
||||||
|
|
||||||
|
static MojangAssetIndexInfoPtr assetIndexFromJson (const QJsonObject &obj);
|
||||||
|
static MojangDownloadInfoPtr downloadInfoFromJson (const QJsonObject &obj);
|
||||||
|
static MojangLibraryDownloadInfoPtr libDownloadInfoFromJson (const QJsonObject &libObj);
|
||||||
|
static QJsonObject assetIndexToJson (MojangAssetIndexInfoPtr assetidxinfo);
|
||||||
|
static QJsonObject libDownloadInfoToJson (MojangLibraryDownloadInfoPtr libinfo);
|
||||||
|
static QJsonObject downloadInfoToJson (MojangDownloadInfoPtr info);
|
||||||
};
|
};
|
||||||
|
@ -153,9 +153,9 @@ VersionFilePtr parseBinaryJsonFile(const QFileInfo &fileInfo)
|
|||||||
|
|
||||||
void removeLwjglFromPatch(VersionFilePtr patch)
|
void removeLwjglFromPatch(VersionFilePtr patch)
|
||||||
{
|
{
|
||||||
auto filter = [](QList<RawLibraryPtr>& libs)
|
auto filter = [](QList<LibraryPtr>& libs)
|
||||||
{
|
{
|
||||||
QList<RawLibraryPtr> filteredLibs;
|
QList<LibraryPtr> filteredLibs;
|
||||||
for (auto lib : libs)
|
for (auto lib : libs)
|
||||||
{
|
{
|
||||||
if (!g_VersionFilterData.lwjglWhitelist.contains(lib->artifactPrefix()))
|
if (!g_VersionFilterData.lwjglWhitelist.contains(lib->artifactPrefix()))
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "RawLibrary.h"
|
#include "Library.h"
|
||||||
#include "VersionFile.h"
|
#include "VersionFile.h"
|
||||||
|
|
||||||
namespace ProfileUtils
|
namespace ProfileUtils
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
|
||||||
#include "OneSixRule.h"
|
#include "Rule.h"
|
||||||
|
|
||||||
RuleAction RuleAction_fromString(QString name)
|
RuleAction RuleAction_fromString(QString name)
|
||||||
{
|
{
|
@ -21,7 +21,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include "OpSys.h"
|
#include "OpSys.h"
|
||||||
|
|
||||||
class RawLibrary;
|
class Library;
|
||||||
class Rule;
|
class Rule;
|
||||||
|
|
||||||
enum RuleAction
|
enum RuleAction
|
||||||
@ -37,7 +37,7 @@ class Rule
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
RuleAction m_result;
|
RuleAction m_result;
|
||||||
virtual bool applies(const RawLibrary *parent) = 0;
|
virtual bool applies(const Library *parent) = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Rule(RuleAction result) : m_result(result)
|
Rule(RuleAction result) : m_result(result)
|
||||||
@ -45,7 +45,7 @@ public:
|
|||||||
}
|
}
|
||||||
virtual ~Rule() {};
|
virtual ~Rule() {};
|
||||||
virtual QJsonObject toJson() = 0;
|
virtual QJsonObject toJson() = 0;
|
||||||
RuleAction apply(const RawLibrary *parent)
|
RuleAction apply(const Library *parent)
|
||||||
{
|
{
|
||||||
if (applies(parent))
|
if (applies(parent))
|
||||||
return m_result;
|
return m_result;
|
||||||
@ -63,7 +63,7 @@ private:
|
|||||||
QString m_version_regexp;
|
QString m_version_regexp;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool applies(const RawLibrary *)
|
virtual bool applies(const Library *)
|
||||||
{
|
{
|
||||||
return (m_system == currentSystem);
|
return (m_system == currentSystem);
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ public:
|
|||||||
class ImplicitRule : public Rule
|
class ImplicitRule : public Rule
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
virtual bool applies(const RawLibrary *)
|
virtual bool applies(const Library *)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
@ -4,7 +4,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "minecraft/VersionFile.h"
|
#include "minecraft/VersionFile.h"
|
||||||
#include "minecraft/RawLibrary.h"
|
#include "minecraft/Library.h"
|
||||||
#include "minecraft/MinecraftProfile.h"
|
#include "minecraft/MinecraftProfile.h"
|
||||||
#include "minecraft/JarMod.h"
|
#include "minecraft/JarMod.h"
|
||||||
#include "ParseUtils.h"
|
#include "ParseUtils.h"
|
||||||
@ -12,7 +12,7 @@
|
|||||||
#include "VersionBuildError.h"
|
#include "VersionBuildError.h"
|
||||||
#include <Version.h>
|
#include <Version.h>
|
||||||
|
|
||||||
int findLibraryByName(QList<RawLibraryPtr> haystack, const GradleSpecifier &needle)
|
int findLibraryByName(QList<LibraryPtr> haystack, const GradleSpecifier &needle)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
for (int i = 0; i < haystack.size(); ++i)
|
for (int i = 0; i < haystack.size(); ++i)
|
||||||
@ -112,10 +112,10 @@ void VersionFile::applyTo(MinecraftProfile *version)
|
|||||||
version->traits.unite(traits);
|
version->traits.unite(traits);
|
||||||
if (shouldOverwriteLibs)
|
if (shouldOverwriteLibs)
|
||||||
{
|
{
|
||||||
QList<RawLibraryPtr> libs;
|
QList<LibraryPtr> libs;
|
||||||
for (auto lib : overwriteLibs)
|
for (auto lib : overwriteLibs)
|
||||||
{
|
{
|
||||||
libs.append(RawLibrary::limitedCopy(lib));
|
libs.append(Library::limitedCopy(lib));
|
||||||
}
|
}
|
||||||
if (isMinecraftVersion())
|
if (isMinecraftVersion())
|
||||||
{
|
{
|
||||||
@ -130,14 +130,14 @@ void VersionFile::applyTo(MinecraftProfile *version)
|
|||||||
// library not found? just add it.
|
// library not found? just add it.
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
{
|
{
|
||||||
version->libraries.append(RawLibrary::limitedCopy(addedLibrary));
|
version->libraries.append(Library::limitedCopy(addedLibrary));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto existingLibrary = version->libraries.at(index);
|
auto existingLibrary = version->libraries.at(index);
|
||||||
// if we are higher it means we should update
|
// if we are higher it means we should update
|
||||||
if (Version(addedLibrary->version()) > Version(existingLibrary->version()))
|
if (Version(addedLibrary->version()) > Version(existingLibrary->version()))
|
||||||
{
|
{
|
||||||
auto library = RawLibrary::limitedCopy(addedLibrary);
|
auto library = Library::limitedCopy(addedLibrary);
|
||||||
version->libraries.replace(index, library);
|
version->libraries.replace(index, library);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "minecraft/OpSys.h"
|
#include "minecraft/OpSys.h"
|
||||||
#include "minecraft/OneSixRule.h"
|
#include "minecraft/Rule.h"
|
||||||
#include "ProfilePatch.h"
|
#include "ProfilePatch.h"
|
||||||
#include "RawLibrary.h"
|
#include "Library.h"
|
||||||
#include "JarMod.h"
|
#include "JarMod.h"
|
||||||
|
|
||||||
class MinecraftProfile;
|
class MinecraftProfile;
|
||||||
@ -169,16 +169,22 @@ public: /* data */
|
|||||||
|
|
||||||
/// MultiMC: override list of libraries (replaces the previously assembled lists)
|
/// MultiMC: override list of libraries (replaces the previously assembled lists)
|
||||||
bool shouldOverwriteLibs = false;
|
bool shouldOverwriteLibs = false;
|
||||||
QList<RawLibraryPtr> overwriteLibs;
|
QList<LibraryPtr> overwriteLibs;
|
||||||
|
|
||||||
/// Mojang: list of libraries to add to the version
|
/// Mojang: list of libraries to add to the version
|
||||||
QList<RawLibraryPtr> addLibs;
|
QList<LibraryPtr> addLibs;
|
||||||
|
|
||||||
/// MultiMC: list of attached traits of this version file - used to enable features
|
/// MultiMC: list of attached traits of this version file - used to enable features
|
||||||
QSet<QString> traits;
|
QSet<QString> traits;
|
||||||
|
|
||||||
/// MultiMC: list of jar mods added to this version
|
/// MultiMC: list of jar mods added to this version
|
||||||
QList<JarmodPtr> jarMods;
|
QList<JarmodPtr> jarMods;
|
||||||
|
|
||||||
|
// Mojang: list of 'downloads' - client jar, server jar, windows server exe, maybe more.
|
||||||
|
QMap <QString, MojangDownloadInfoPtr> mojangDownloads;
|
||||||
|
|
||||||
|
// Mojang: extended asset index download information
|
||||||
|
MojangAssetIndexInfoPtr mojangAssetIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ void FTBProfileStrategy::loadDefaultBuiltinPatches()
|
|||||||
file->id.clear();
|
file->id.clear();
|
||||||
for(auto addLib: file->addLibs)
|
for(auto addLib: file->addLibs)
|
||||||
{
|
{
|
||||||
addLib->m_hint = "local";
|
addLib->setHint("local");
|
||||||
addLib->setStoragePrefix(nativeInstance->librariesPath().absolutePath());
|
addLib->setStoragePrefix(nativeInstance->librariesPath().absolutePath());
|
||||||
}
|
}
|
||||||
file->fileId = "org.multimc.ftb.pack";
|
file->fileId = "org.multimc.ftb.pack";
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "minecraft/MinecraftProfile.h"
|
#include "minecraft/MinecraftProfile.h"
|
||||||
#include "minecraft/RawLibrary.h"
|
#include "minecraft/Library.h"
|
||||||
#include "minecraft/onesix/OneSixInstance.h"
|
#include "minecraft/onesix/OneSixInstance.h"
|
||||||
#include <minecraft/onesix/OneSixVersionFormat.h>
|
#include <minecraft/onesix/OneSixVersionFormat.h>
|
||||||
#include "minecraft/liteloader/LiteLoaderVersionList.h"
|
#include "minecraft/liteloader/LiteLoaderVersionList.h"
|
||||||
@ -50,14 +50,14 @@ bool LiteLoaderInstaller::add(OneSixInstance *to)
|
|||||||
|
|
||||||
QJsonArray libraries;
|
QJsonArray libraries;
|
||||||
|
|
||||||
for (auto rawLibrary : m_version->libraries)
|
for (auto Library : m_version->libraries)
|
||||||
{
|
{
|
||||||
libraries.append(OneSixVersionFormat::libraryToJson(rawLibrary.get()));
|
libraries.append(OneSixVersionFormat::libraryToJson(Library.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// liteloader
|
// liteloader
|
||||||
{
|
{
|
||||||
RawLibrary liteloaderLib("com.mumfrey:liteloader:" + m_version->version);
|
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));
|
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);
|
QJsonObject llLibObj = OneSixVersionFormat::libraryToJson(&liteloaderLib);
|
||||||
libraries.append(llLibObj);
|
libraries.append(llLibObj);
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include "BaseVersionList.h"
|
#include "BaseVersionList.h"
|
||||||
#include "tasks/Task.h"
|
#include "tasks/Task.h"
|
||||||
#include "net/NetJob.h"
|
#include "net/NetJob.h"
|
||||||
#include <minecraft/RawLibrary.h>
|
#include <minecraft/Library.h>
|
||||||
|
|
||||||
#include "multimc_logic_export.h"
|
#include "multimc_logic_export.h"
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ public:
|
|||||||
int timestamp;
|
int timestamp;
|
||||||
bool isLatest;
|
bool isLatest;
|
||||||
QString tweakClass;
|
QString tweakClass;
|
||||||
QList<RawLibraryPtr> libraries;
|
QList<LibraryPtr> libraries;
|
||||||
|
|
||||||
// meta
|
// meta
|
||||||
QString defaultUrl;
|
QString defaultUrl;
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
#include "minecraft/MinecraftVersionList.h"
|
#include "minecraft/MinecraftVersionList.h"
|
||||||
#include "minecraft/MinecraftProfile.h"
|
#include "minecraft/MinecraftProfile.h"
|
||||||
#include "minecraft/RawLibrary.h"
|
#include "minecraft/Library.h"
|
||||||
#include "minecraft/forge/ForgeMirrors.h"
|
#include "minecraft/forge/ForgeMirrors.h"
|
||||||
#include "net/URLConstants.h"
|
#include "net/URLConstants.h"
|
||||||
#include "minecraft/AssetsUtils.h"
|
#include "minecraft/AssetsUtils.h"
|
||||||
@ -213,7 +213,7 @@ void OneSixUpdate::jarlibStart()
|
|||||||
|
|
||||||
auto metacache = ENV.metacache();
|
auto metacache = ENV.metacache();
|
||||||
QList<ForgeXzDownloadPtr> ForgeLibs;
|
QList<ForgeXzDownloadPtr> ForgeLibs;
|
||||||
QList<RawLibraryPtr> brokenLocalLibs;
|
QList<LibraryPtr> brokenLocalLibs;
|
||||||
|
|
||||||
for (auto lib : libs)
|
for (auto lib : libs)
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "minecraft/ParseUtils.h"
|
#include "minecraft/ParseUtils.h"
|
||||||
#include <minecraft/MinecraftVersion.h>
|
#include <minecraft/MinecraftVersion.h>
|
||||||
#include <minecraft/VersionBuildError.h>
|
#include <minecraft/VersionBuildError.h>
|
||||||
|
#include <minecraft/MojangVersionFormat.h>
|
||||||
|
|
||||||
using namespace Json;
|
using namespace Json;
|
||||||
|
|
||||||
@ -24,99 +25,22 @@ static QString readStringRet(const QJsonObject &root, const QString &key)
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
RawLibraryPtr OneSixVersionFormat::libraryFromJson(const QJsonObject &libObj, const QString &filename)
|
LibraryPtr OneSixVersionFormat::libraryFromJson(const QJsonObject &libObj, const QString &filename)
|
||||||
{
|
{
|
||||||
RawLibraryPtr out(new RawLibrary());
|
LibraryPtr out = MojangVersionFormat::libraryFromJson(libObj, filename);
|
||||||
if (!libObj.contains("name"))
|
|
||||||
{
|
|
||||||
throw JSONValidationError(filename +
|
|
||||||
"contains a library that doesn't have a 'name' field");
|
|
||||||
}
|
|
||||||
out->m_name = libObj.value("name").toString();
|
|
||||||
|
|
||||||
readString(libObj, "url", out->m_base_url);
|
|
||||||
readString(libObj, "MMC-hint", out->m_hint);
|
readString(libObj, "MMC-hint", out->m_hint);
|
||||||
readString(libObj, "MMC-absulute_url", out->m_absolute_url);
|
readString(libObj, "MMC-absulute_url", out->m_absolute_url);
|
||||||
readString(libObj, "MMC-absoluteUrl", out->m_absolute_url);
|
readString(libObj, "MMC-absoluteUrl", out->m_absolute_url);
|
||||||
if (libObj.contains("extract"))
|
|
||||||
{
|
|
||||||
out->applyExcludes = true;
|
|
||||||
auto extractObj = requireObject(libObj.value("extract"));
|
|
||||||
for (auto excludeVal : requireArray(extractObj.value("exclude")))
|
|
||||||
{
|
|
||||||
out->extract_excludes.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)";
|
|
||||||
}
|
|
||||||
OpSys opSys = OpSys_fromString(it.key());
|
|
||||||
if (opSys != Os_Other)
|
|
||||||
{
|
|
||||||
out->m_native_classifiers[opSys] = it.value().toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (libObj.contains("rules"))
|
|
||||||
{
|
|
||||||
out->applyRules = true;
|
|
||||||
out->m_rules = rulesFromJsonV4(libObj);
|
|
||||||
}
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject OneSixVersionFormat::libraryToJson(RawLibrary *library)
|
QJsonObject OneSixVersionFormat::libraryToJson(Library *library)
|
||||||
{
|
{
|
||||||
QJsonObject libRoot;
|
QJsonObject libRoot = MojangVersionFormat::libraryToJson(library);
|
||||||
libRoot.insert("name", (QString)library->m_name);
|
|
||||||
if (library->m_absolute_url.size())
|
if (library->m_absolute_url.size())
|
||||||
libRoot.insert("MMC-absoluteUrl", library->m_absolute_url);
|
libRoot.insert("MMC-absoluteUrl", library->m_absolute_url);
|
||||||
if (library->m_hint.size())
|
if (library->m_hint.size())
|
||||||
libRoot.insert("MMC-hint", library->m_hint);
|
libRoot.insert("MMC-hint", library->m_hint);
|
||||||
if (library->m_base_url != "http://" + URLConstants::AWS_DOWNLOAD_LIBRARIES &&
|
|
||||||
library->m_base_url != "https://" + URLConstants::AWS_DOWNLOAD_LIBRARIES &&
|
|
||||||
library->m_base_url != "https://" + URLConstants::LIBRARY_BASE && !library->m_base_url.isEmpty())
|
|
||||||
{
|
|
||||||
libRoot.insert("url", library->m_base_url);
|
|
||||||
}
|
|
||||||
if (library->isNative())
|
|
||||||
{
|
|
||||||
QJsonObject nativeList;
|
|
||||||
auto iter = library->m_native_classifiers.begin();
|
|
||||||
while (iter != library->m_native_classifiers.end())
|
|
||||||
{
|
|
||||||
nativeList.insert(OpSys_toString(iter.key()), iter.value());
|
|
||||||
iter++;
|
|
||||||
}
|
|
||||||
libRoot.insert("natives", nativeList);
|
|
||||||
if (library->extract_excludes.size())
|
|
||||||
{
|
|
||||||
QJsonArray excludes;
|
|
||||||
QJsonObject extract;
|
|
||||||
for (auto exclude : library->extract_excludes)
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
return libRoot;
|
return libRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,7 +177,7 @@ VersionFilePtr OneSixVersionFormat::versionFileFromJson(const QJsonDocument &doc
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
struct libraryConversion
|
struct libraryConversion
|
||||||
{
|
{
|
||||||
static QJsonObject convert(std::shared_ptr<RawLibrary> &value)
|
static QJsonObject convert(std::shared_ptr<Library> &value)
|
||||||
{
|
{
|
||||||
return OneSixVersionFormat::libraryToJson(value.get());
|
return OneSixVersionFormat::libraryToJson(value.get());
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <minecraft/VersionFile.h>
|
#include <minecraft/VersionFile.h>
|
||||||
#include <minecraft/MinecraftProfile.h>
|
#include <minecraft/MinecraftProfile.h>
|
||||||
#include <minecraft/RawLibrary.h>
|
#include <minecraft/Library.h>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
|
||||||
class OneSixVersionFormat
|
class OneSixVersionFormat
|
||||||
@ -16,8 +16,8 @@ public:
|
|||||||
static QJsonDocument profilePatchToJson(const ProfilePatchPtr &patch, bool saveOrder);
|
static QJsonDocument profilePatchToJson(const ProfilePatchPtr &patch, bool saveOrder);
|
||||||
|
|
||||||
// libraries
|
// libraries
|
||||||
static RawLibraryPtr libraryFromJson(const QJsonObject &libObj, const QString &filename);
|
static LibraryPtr libraryFromJson(const QJsonObject &libObj, const QString &filename);
|
||||||
static QJsonObject libraryToJson(RawLibrary *library);
|
static QJsonObject libraryToJson(Library *library);
|
||||||
|
|
||||||
// jar mods
|
// jar mods
|
||||||
static JarmodPtr jarModFromJson(const QJsonObject &libObj, const QString &filename, const QString &originalName);
|
static JarmodPtr jarModFromJson(const QJsonObject &libObj, const QString &filename, const QString &originalName);
|
||||||
|
@ -34,21 +34,19 @@ slots:
|
|||||||
QJsonDocument doc = readJson("tests/data/1.9-simple.json");
|
QJsonDocument doc = readJson("tests/data/1.9-simple.json");
|
||||||
auto vfile = MojangVersionFormat::versionFileFromJson(doc, "1.9-simple.json");
|
auto vfile = MojangVersionFormat::versionFileFromJson(doc, "1.9-simple.json");
|
||||||
auto doc2 = MojangVersionFormat::profilePatchToJson(vfile);
|
auto doc2 = MojangVersionFormat::profilePatchToJson(vfile);
|
||||||
writeJson("beast.json", doc2);
|
writeJson("1.9-simple-passthorugh.json", doc2);
|
||||||
QCOMPARE(doc, doc2);
|
QCOMPARE(doc, doc2);
|
||||||
}
|
}
|
||||||
// not yet
|
|
||||||
/*
|
|
||||||
void test_Through()
|
void test_Through()
|
||||||
{
|
{
|
||||||
|
|
||||||
QJsonDocument doc = readJson("tests/data/1.9.json");
|
QJsonDocument doc = readJson("tests/data/1.9.json");
|
||||||
auto vfile = MojangVersionFormat::versionFileFromJson(doc, "1.9.json");
|
auto vfile = MojangVersionFormat::versionFileFromJson(doc, "1.9.json");
|
||||||
auto doc2 = MojangVersionFormat::profilePatchToJson(vfile);
|
auto doc2 = MojangVersionFormat::profilePatchToJson(vfile);
|
||||||
|
writeJson("1.9-passthorugh.json", doc2);
|
||||||
QCOMPARE(doc, doc2);
|
QCOMPARE(doc, doc2);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
QTEST_GUILESS_MAIN(MojangVersionFormatTest)
|
QTEST_GUILESS_MAIN(MojangVersionFormatTest)
|
||||||
|
Loading…
Reference in New Issue
Block a user