2014-03-01 23:06:47 +01:00
|
|
|
#include <QJsonArray>
|
|
|
|
#include <QJsonDocument>
|
|
|
|
|
2015-02-02 02:14:14 +01:00
|
|
|
#include <QDebug>
|
2014-05-08 21:20:10 +02:00
|
|
|
|
2015-02-09 01:51:14 +01:00
|
|
|
#include "minecraft/VersionFile.h"
|
2016-03-07 02:01:28 +01:00
|
|
|
#include "minecraft/Library.h"
|
2015-02-09 01:51:14 +01:00
|
|
|
#include "minecraft/MinecraftProfile.h"
|
|
|
|
#include "minecraft/JarMod.h"
|
2014-05-10 01:53:32 +02:00
|
|
|
#include "ParseUtils.h"
|
2014-03-01 23:06:47 +01:00
|
|
|
|
2014-05-10 01:53:32 +02:00
|
|
|
#include "VersionBuildError.h"
|
2015-10-05 01:47:27 +02:00
|
|
|
#include <Version.h>
|
2014-05-10 01:53:32 +02:00
|
|
|
|
2014-05-11 12:37:21 +02:00
|
|
|
bool VersionFile::isMinecraftVersion()
|
2014-04-23 02:27:40 +02:00
|
|
|
{
|
2015-01-27 22:31:07 +01:00
|
|
|
return fileId == "net.minecraft";
|
2014-04-23 02:27:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool VersionFile::hasJarMods()
|
|
|
|
{
|
|
|
|
return !jarMods.isEmpty();
|
|
|
|
}
|
|
|
|
|
2016-03-13 20:57:01 +01:00
|
|
|
void VersionFile::applyTo(MinecraftProfile *profile)
|
2014-03-01 23:06:47 +01:00
|
|
|
{
|
2016-03-13 20:57:01 +01:00
|
|
|
auto theirVersion = profile->getMinecraftVersion();
|
2016-03-13 00:23:45 +01:00
|
|
|
if (!theirVersion.isNull() && !mcVersion.isNull())
|
2014-03-01 23:06:47 +01:00
|
|
|
{
|
2016-03-13 00:23:45 +01:00
|
|
|
if (QRegExp(mcVersion, Qt::CaseInsensitive, QRegExp::Wildcard).indexIn(theirVersion) == -1)
|
2014-04-23 02:27:40 +02:00
|
|
|
{
|
2016-03-13 00:23:45 +01:00
|
|
|
throw MinecraftVersionMismatch(fileId, mcVersion, theirVersion);
|
2014-04-23 02:27:40 +02:00
|
|
|
}
|
2014-03-01 23:06:47 +01:00
|
|
|
}
|
2016-03-13 20:57:01 +01:00
|
|
|
profile->applyMinecraftVersion(id);
|
|
|
|
profile->applyMainClass(mainClass);
|
|
|
|
profile->applyAppletClass(appletClass);
|
|
|
|
profile->applyMinecraftArguments(minecraftArguments);
|
2016-03-13 02:28:55 +01:00
|
|
|
if (isMinecraftVersion())
|
2014-03-01 23:06:47 +01:00
|
|
|
{
|
2016-03-13 20:57:01 +01:00
|
|
|
profile->applyMinecraftVersionType(type);
|
2014-03-01 23:06:47 +01:00
|
|
|
}
|
2016-03-13 20:57:01 +01:00
|
|
|
profile->applyMinecraftAssets(assets);
|
|
|
|
profile->applyTweakers(addTweakers);
|
2016-03-13 00:23:45 +01:00
|
|
|
|
2016-03-13 20:57:01 +01:00
|
|
|
profile->applyJarMods(jarMods);
|
|
|
|
profile->applyTraits(traits);
|
2016-03-13 00:23:45 +01:00
|
|
|
|
2016-03-13 02:28:55 +01:00
|
|
|
for (auto library : libraries)
|
2014-03-01 23:06:47 +01:00
|
|
|
{
|
2016-03-13 20:57:01 +01:00
|
|
|
profile->applyLibrary(library);
|
2014-03-01 23:06:47 +01:00
|
|
|
}
|
2016-03-18 15:02:54 +01:00
|
|
|
profile->applyProblemSeverity(getProblemSeverity());
|
2014-03-01 23:06:47 +01:00
|
|
|
}
|