NOISSUE clean up forge installer
This commit is contained in:
parent
576d808d71
commit
010e07eb45
@ -185,7 +185,6 @@ set(LOGIC_SOURCES
|
|||||||
minecraft/MinecraftVersion.h
|
minecraft/MinecraftVersion.h
|
||||||
minecraft/MinecraftVersionList.cpp
|
minecraft/MinecraftVersionList.cpp
|
||||||
minecraft/MinecraftVersionList.h
|
minecraft/MinecraftVersionList.h
|
||||||
minecraft/NullProfileStrategy.h
|
|
||||||
minecraft/Rule.cpp
|
minecraft/Rule.cpp
|
||||||
minecraft/Rule.h
|
minecraft/Rule.h
|
||||||
minecraft/OpSys.cpp
|
minecraft/OpSys.cpp
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "minecraft/MinecraftProfile.h"
|
#include "minecraft/MinecraftProfile.h"
|
||||||
#include "ProfileUtils.h"
|
#include "ProfileUtils.h"
|
||||||
#include "NullProfileStrategy.h"
|
#include "ProfileStrategy.h"
|
||||||
#include "Exception.h"
|
#include "Exception.h"
|
||||||
|
|
||||||
MinecraftProfile::MinecraftProfile(ProfileStrategy *strategy)
|
MinecraftProfile::MinecraftProfile(ProfileStrategy *strategy)
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "ProfileStrategy.h"
|
|
||||||
|
|
||||||
class NullProfileStrategy: public ProfileStrategy
|
|
||||||
{
|
|
||||||
virtual bool installJarMods(QStringList filepaths)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
virtual void load() {};
|
|
||||||
virtual bool removePatch(ProfilePatchPtr jarMod)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
virtual bool customizePatch(ProfilePatchPtr patch)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
virtual bool revertPatch(ProfilePatchPtr patch)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
virtual bool resetOrder()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
virtual bool saveOrder(ProfileUtils::PatchOrder order)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
@ -23,6 +23,7 @@
|
|||||||
#include "minecraft/onesix/OneSixInstance.h"
|
#include "minecraft/onesix/OneSixInstance.h"
|
||||||
#include <minecraft/onesix/OneSixVersionFormat.h>
|
#include <minecraft/onesix/OneSixVersionFormat.h>
|
||||||
#include "minecraft/VersionFilterData.h"
|
#include "minecraft/VersionFilterData.h"
|
||||||
|
#include "minecraft/MinecraftVersion.h"
|
||||||
#include "Env.h"
|
#include "Env.h"
|
||||||
#include "Exception.h"
|
#include "Exception.h"
|
||||||
#include <FileSystem.h>
|
#include <FileSystem.h>
|
||||||
@ -44,7 +45,7 @@ ForgeInstaller::ForgeInstaller() : BaseInstaller()
|
|||||||
|
|
||||||
void ForgeInstaller::prepare(const QString &filename, const QString &universalUrl)
|
void ForgeInstaller::prepare(const QString &filename, const QString &universalUrl)
|
||||||
{
|
{
|
||||||
std::shared_ptr<MinecraftProfile> newVersion;
|
VersionFilePtr newVersion;
|
||||||
m_universal_url = universalUrl;
|
m_universal_url = universalUrl;
|
||||||
|
|
||||||
QuaZip zip(filename);
|
QuaZip zip(filename);
|
||||||
@ -75,11 +76,13 @@ void ForgeInstaller::prepare(const QString &filename, const QString &universalUr
|
|||||||
if (!installVal.isObject() || !versionInfoVal.isObject())
|
if (!installVal.isObject() || !versionInfoVal.isObject())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// read the forge version info
|
try
|
||||||
{
|
{
|
||||||
newVersion = OneSixVersionFormat::profileFromSingleJson(versionInfoVal.toObject());
|
newVersion = OneSixVersionFormat::versionFileFromJson(QJsonDocument(versionInfoVal.toObject()), QString(), false);
|
||||||
if (!newVersion)
|
}
|
||||||
return;
|
catch(Exception &err)
|
||||||
|
{
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject installObj = installVal.toObject();
|
QJsonObject installObj = installVal.toObject();
|
||||||
@ -119,7 +122,6 @@ void ForgeInstaller::prepare(const QString &filename, const QString &universalUr
|
|||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
m_forge_json = newVersion;
|
m_forge_json = newVersion;
|
||||||
//m_forge_json->id = installObj.value("minecraft").toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ForgeInstaller::add(OneSixInstance *to)
|
bool ForgeInstaller::add(OneSixInstance *to)
|
||||||
@ -129,130 +131,141 @@ bool ForgeInstaller::add(OneSixInstance *to)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject obj;
|
|
||||||
obj.insert("order", 5);
|
|
||||||
|
|
||||||
if (!m_forge_json)
|
if (!m_forge_json)
|
||||||
return false;
|
|
||||||
{
|
{
|
||||||
QJsonArray libraries;
|
return false;
|
||||||
// A blacklist
|
}
|
||||||
QSet<QString> blacklist{"authlib", "realms"};
|
|
||||||
//
|
// A blacklist
|
||||||
QList<QString> xzlist{"org.scala-lang", "com.typesafe"};
|
QSet<QString> blacklist{"authlib", "realms"};
|
||||||
// for each library in the version we are adding (except for the blacklisted)
|
QList<QString> xzlist{"org.scala-lang", "com.typesafe"};
|
||||||
for (auto lib : m_forge_json->getLibraries())
|
|
||||||
|
// get the minecraft version from the instance
|
||||||
|
VersionFilePtr minecraft;
|
||||||
|
auto minecraftPatch = to->getMinecraftProfile()->versionPatch("net.minecraft");
|
||||||
|
if(minecraftPatch)
|
||||||
|
{
|
||||||
|
minecraft = std::dynamic_pointer_cast<VersionFile>(minecraftPatch);
|
||||||
|
if(!minecraft)
|
||||||
{
|
{
|
||||||
QString libName = lib->artifactId();
|
auto mcWrap = std::dynamic_pointer_cast<MinecraftVersion>(minecraftPatch);
|
||||||
QString rawName = lib->rawName();
|
if(mcWrap)
|
||||||
|
|
||||||
// ignore lwjgl libraries.
|
|
||||||
if (g_VersionFilterData.lwjglWhitelist.contains(lib->artifactPrefix()))
|
|
||||||
continue;
|
|
||||||
// ignore other blacklisted (realms, authlib)
|
|
||||||
if (blacklist.contains(libName))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// WARNING: This could actually break.
|
|
||||||
// if this is the actual forge lib, set an absolute url for the download
|
|
||||||
if (m_forge_version->type == ForgeVersion::Gradle)
|
|
||||||
{
|
{
|
||||||
if (libName == "forge")
|
minecraft = mcWrap->getVersionFile();
|
||||||
{
|
|
||||||
lib->setClassifier("universal");
|
|
||||||
}
|
|
||||||
else if (libName == "minecraftforge")
|
|
||||||
{
|
|
||||||
QString forgeCoord("net.minecraftforge:forge:%1:universal");
|
|
||||||
// using insane form of the MC version...
|
|
||||||
QString longVersion =
|
|
||||||
m_forge_version->mcver + "-" + m_forge_version->jobbuildver;
|
|
||||||
GradleSpecifier spec(forgeCoord.arg(longVersion));
|
|
||||||
lib->setRawName(spec);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (libName.contains("minecraftforge"))
|
|
||||||
{
|
|
||||||
lib->setAbsoluteUrl(m_universal_url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// WARNING: This could actually break.
|
|
||||||
// mark bad libraries based on the xzlist above
|
|
||||||
for (auto entry : xzlist)
|
|
||||||
{
|
|
||||||
qDebug() << "Testing " << rawName << " : " << entry;
|
|
||||||
if (rawName.startsWith(entry))
|
|
||||||
{
|
|
||||||
lib->setHint("forge-pack-xz");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QJsonObject libObj = OneSixVersionFormat::libraryToJson(lib.get());
|
|
||||||
|
|
||||||
// FIXME: use upstream Minecraft version files instead, not the processed profile!
|
|
||||||
/*
|
|
||||||
bool equals = false;
|
|
||||||
// find an entry that matches this one
|
|
||||||
for (auto tolib : to->getMinecraftProfile()->getVanillaLibraries())
|
|
||||||
{
|
|
||||||
if (tolib->artifactId() != libName)
|
|
||||||
continue;
|
|
||||||
if (OneSixVersionFormat::libraryToJson(tolib.get()) == libObj)
|
|
||||||
{
|
|
||||||
equals = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (equals)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
libraries.append(libObj);
|
|
||||||
}
|
|
||||||
obj.insert("libraries", libraries);
|
|
||||||
obj.insert("mainClass", m_forge_json->getMainClass());
|
|
||||||
QString args = m_forge_json->getMinecraftArguments();
|
|
||||||
QStringList tweakers;
|
|
||||||
{
|
|
||||||
QRegularExpression expression("--tweakClass ([a-zA-Z0-9\\.]*)");
|
|
||||||
QRegularExpressionMatch match = expression.match(args);
|
|
||||||
while (match.hasMatch())
|
|
||||||
{
|
|
||||||
tweakers.append(match.captured(1));
|
|
||||||
args.remove(match.capturedStart(), match.capturedLength());
|
|
||||||
match = expression.match(args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// FIXME: use upstream Minecraft version files instead, not the processed profile!
|
|
||||||
if (!args.isEmpty() /* && args != to->getMinecraftProfile()->getVanillaMinecraftArguments() */)
|
|
||||||
{
|
|
||||||
obj.insert("minecraftArguments", args);
|
|
||||||
}
|
|
||||||
if (!tweakers.isEmpty())
|
|
||||||
{
|
|
||||||
obj.insert("+tweakers", QJsonArray::fromStringList(tweakers));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
obj.insert("name", QString("Forge"));
|
// for each library in the version we are adding (except for the blacklisted)
|
||||||
obj.insert("fileId", id());
|
QMutableListIterator<LibraryPtr> iter(m_forge_json->libraries);
|
||||||
obj.insert("version", m_forgeVersionString);
|
while (iter.hasNext())
|
||||||
obj.insert("mcVersion", to->intendedVersionId());
|
{
|
||||||
|
auto library = iter.next();
|
||||||
|
QString libName = library->artifactId();
|
||||||
|
QString libVersion = library->version();
|
||||||
|
QString rawName = library->rawName();
|
||||||
|
|
||||||
QFile file(filename(to->instanceRoot()));
|
// ignore lwjgl libraries.
|
||||||
|
if (g_VersionFilterData.lwjglWhitelist.contains(library->artifactPrefix()))
|
||||||
|
{
|
||||||
|
iter.remove();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// ignore other blacklisted (realms, authlib)
|
||||||
|
if (blacklist.contains(libName))
|
||||||
|
{
|
||||||
|
iter.remove();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// if minecraft version was found, ignore everything that is already in the minecraft version
|
||||||
|
if(minecraft)
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
for (auto & lib: minecraft->libraries)
|
||||||
|
{
|
||||||
|
if(library->artifactPrefix() == lib->artifactPrefix() && library->version() == lib->version())
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if this is the actual forge lib, set an absolute url for the download
|
||||||
|
if (m_forge_version->type == ForgeVersion::Gradle)
|
||||||
|
{
|
||||||
|
if (libName == "forge")
|
||||||
|
{
|
||||||
|
library->setClassifier("universal");
|
||||||
|
}
|
||||||
|
else if (libName == "minecraftforge")
|
||||||
|
{
|
||||||
|
QString forgeCoord("net.minecraftforge:forge:%1:universal");
|
||||||
|
// using insane form of the MC version...
|
||||||
|
QString longVersion = m_forge_version->mcver + "-" + m_forge_version->jobbuildver;
|
||||||
|
GradleSpecifier spec(forgeCoord.arg(longVersion));
|
||||||
|
library->setRawName(spec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (libName.contains("minecraftforge"))
|
||||||
|
{
|
||||||
|
library->setAbsoluteUrl(m_universal_url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// mark bad libraries based on the xzlist above
|
||||||
|
for (auto entry : xzlist)
|
||||||
|
{
|
||||||
|
qDebug() << "Testing " << rawName << " : " << entry;
|
||||||
|
if (rawName.startsWith(entry))
|
||||||
|
{
|
||||||
|
library->setHint("forge-pack-xz");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QString &args = m_forge_json->minecraftArguments;
|
||||||
|
QStringList tweakers;
|
||||||
|
{
|
||||||
|
QRegularExpression expression("--tweakClass ([a-zA-Z0-9\\.]*)");
|
||||||
|
QRegularExpressionMatch match = expression.match(args);
|
||||||
|
while (match.hasMatch())
|
||||||
|
{
|
||||||
|
tweakers.append(match.captured(1));
|
||||||
|
args.remove(match.capturedStart(), match.capturedLength());
|
||||||
|
match = expression.match(args);
|
||||||
|
}
|
||||||
|
if(tweakers.size())
|
||||||
|
{
|
||||||
|
args.operator=(args.trimmed());
|
||||||
|
m_forge_json->addTweakers = tweakers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(minecraft && args == minecraft->minecraftArguments)
|
||||||
|
{
|
||||||
|
args.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_forge_json->name = "Forge";
|
||||||
|
m_forge_json->fileId = id();
|
||||||
|
m_forge_json->version = m_forgeVersionString;
|
||||||
|
m_forge_json->mcVersion = to->intendedVersionId();
|
||||||
|
m_forge_json->id.clear();
|
||||||
|
m_forge_json->order = 5;
|
||||||
|
|
||||||
|
QSaveFile file(filename(to->instanceRoot()));
|
||||||
if (!file.open(QFile::WriteOnly))
|
if (!file.open(QFile::WriteOnly))
|
||||||
{
|
{
|
||||||
qCritical() << "Error opening" << file.fileName()
|
qCritical() << "Error opening" << file.fileName()
|
||||||
<< "for reading:" << file.errorString();
|
<< "for reading:" << file.errorString();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
file.write(QJsonDocument(obj).toJson());
|
file.write(OneSixVersionFormat::profilePatchToJson(m_forge_json, true).toJson());
|
||||||
file.close();
|
file.commit();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "multimc_logic_export.h"
|
#include "multimc_logic_export.h"
|
||||||
|
|
||||||
class MinecraftProfile;
|
class VersionFile;
|
||||||
class ForgeInstallTask;
|
class ForgeInstallTask;
|
||||||
struct ForgeVersion;
|
struct ForgeVersion;
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// the parsed version json, read from the installer
|
// the parsed version json, read from the installer
|
||||||
std::shared_ptr<MinecraftProfile> m_forge_json;
|
std::shared_ptr<VersionFile> m_forge_json;
|
||||||
// the actual forge version
|
// the actual forge version
|
||||||
std::shared_ptr<ForgeVersion> m_forge_version;
|
std::shared_ptr<ForgeVersion> m_forge_version;
|
||||||
QString internalPath;
|
QString internalPath;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "OneSixVersionFormat.h"
|
#include "OneSixVersionFormat.h"
|
||||||
#include <minecraft/NullProfileStrategy.h>
|
|
||||||
#include <Json.h>
|
#include <Json.h>
|
||||||
#include "minecraft/ParseUtils.h"
|
#include "minecraft/ParseUtils.h"
|
||||||
#include <minecraft/MinecraftVersion.h>
|
#include <minecraft/MinecraftVersion.h>
|
||||||
@ -283,23 +282,6 @@ QJsonDocument OneSixVersionFormat::profilePatchToJson(const ProfilePatchPtr &pat
|
|||||||
throw VersionIncomplete(QObject::tr("Unhandled object type while processing %1").arg(patch->getName()));
|
throw VersionIncomplete(QObject::tr("Unhandled object type while processing %1").arg(patch->getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<MinecraftProfile> OneSixVersionFormat::profileFromSingleJson(const QJsonObject &obj)
|
|
||||||
{
|
|
||||||
std::shared_ptr<MinecraftProfile> version(new MinecraftProfile(new NullProfileStrategy()));
|
|
||||||
try
|
|
||||||
{
|
|
||||||
version->clear();
|
|
||||||
auto file = versionFileFromJson(QJsonDocument(obj), QString(), false);
|
|
||||||
file->applyTo(version.get());
|
|
||||||
version->appendPatch(file);
|
|
||||||
}
|
|
||||||
catch(Exception &err)
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
JarmodPtr OneSixVersionFormat::jarModFromJson(const QJsonObject &libObj, const QString &filename, const QString &originalName)
|
JarmodPtr OneSixVersionFormat::jarModFromJson(const QJsonObject &libObj, const QString &filename, const QString &originalName)
|
||||||
{
|
{
|
||||||
JarmodPtr out(new Jarmod());
|
JarmodPtr out(new Jarmod());
|
||||||
|
@ -8,9 +8,6 @@
|
|||||||
class OneSixVersionFormat
|
class OneSixVersionFormat
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// whole profiles from single file
|
|
||||||
static std::shared_ptr<MinecraftProfile> profileFromSingleJson(const QJsonObject &obj);
|
|
||||||
|
|
||||||
// version files / profile patches
|
// version files / profile patches
|
||||||
static VersionFilePtr versionFileFromJson(const QJsonDocument &doc, const QString &filename, const bool requireOrder);
|
static VersionFilePtr versionFileFromJson(const QJsonDocument &doc, const QString &filename, const bool requireOrder);
|
||||||
static QJsonDocument profilePatchToJson(const ProfilePatchPtr &patch, bool saveOrder);
|
static QJsonDocument profilePatchToJson(const ProfilePatchPtr &patch, bool saveOrder);
|
||||||
|
Loading…
Reference in New Issue
Block a user