diff --git a/MultiMC.cpp b/MultiMC.cpp
index 7e7c6c88c..acf05c894 100644
--- a/MultiMC.cpp
+++ b/MultiMC.cpp
@@ -357,6 +357,9 @@ void MultiMC::initGlobalSettings()
m_settings->registerSetting("AutoUpdate", true);
m_settings->registerSetting("IconTheme", QString("multimc"));
+ // Minecraft Sneaky Updates
+ m_settings->registerSetting("AutoUpdateMinecraftVersions", true);
+
// Notifications
m_settings->registerSetting("ShownNotifications", QString());
diff --git a/gui/dialogs/IconPickerDialog.h b/gui/dialogs/IconPickerDialog.h
index 70951da6e..f00c2388a 100644
--- a/gui/dialogs/IconPickerDialog.h
+++ b/gui/dialogs/IconPickerDialog.h
@@ -29,10 +29,7 @@ class IconPickerDialog : public QDialog
public:
explicit IconPickerDialog(QWidget *parent = 0);
~IconPickerDialog();
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Woverloaded-virtual"
int exec(QString selection);
- #pragma clang diagnostic pop
QString selectedIconKey;
protected:
diff --git a/gui/dialogs/ProgressDialog.h b/gui/dialogs/ProgressDialog.h
index 45a6238a4..3276fd7a1 100644
--- a/gui/dialogs/ProgressDialog.h
+++ b/gui/dialogs/ProgressDialog.h
@@ -34,10 +34,7 @@ public:
void updateSize();
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Woverloaded-virtual"
int exec(ProgressProvider *task);
- #pragma clang diagnostic pop
void setSkipButton(bool present, QString label = QString());
diff --git a/gui/dialogs/SettingsDialog.cpp b/gui/dialogs/SettingsDialog.cpp
index 46368bc19..347cd67ea 100644
--- a/gui/dialogs/SettingsDialog.cpp
+++ b/gui/dialogs/SettingsDialog.cpp
@@ -365,6 +365,9 @@ void SettingsDialog::applySettings(SettingsObject *s)
}
s->set("JsonEditor", jsonEditor);
+ // Minecraft version updates
+ s->set("AutoUpdateMinecraftVersions", ui->autoupdateMinecraft->isChecked());
+
// Console
s->set("ShowConsole", ui->showConsoleCheck->isChecked());
s->set("AutoCloseConsole", ui->autoCloseConsoleCheck->isChecked());
@@ -470,6 +473,9 @@ void SettingsDialog::loadSettings(SettingsObject *s)
// Editors
ui->jsonEditorTextBox->setText(s->get("JsonEditor").toString());
+ // Minecraft version updates
+ ui->autoupdateMinecraft->setChecked(s->get("AutoUpdateMinecraftVersions").toBool());
+
// Console
ui->showConsoleCheck->setChecked(s->get("ShowConsole").toBool());
ui->autoCloseConsoleCheck->setChecked(s->get("AutoCloseConsole").toBool());
diff --git a/gui/dialogs/SettingsDialog.ui b/gui/dialogs/SettingsDialog.ui
index d4e903028..94b81dd7c 100644
--- a/gui/dialogs/SettingsDialog.ui
+++ b/gui/dialogs/SettingsDialog.ui
@@ -409,6 +409,22 @@
Minecraft
+ -
+
+
+ Minecraft Version Updates
+
+
+
-
+
+
+ Automatically update to latest version revision
+
+
+
+
+
+
-
@@ -1056,11 +1072,30 @@
- buttonBox
+ settingsTabs
+ autoUpdateCheckBox
+ updateChannelComboBox
+ trackFtbBox
+ ftbLauncherBox
+ ftbLauncherBrowseBtn
+ ftbBox
+ ftbBrowseBtn
+ instDirTextBox
+ instDirBrowseBtn
+ modsDirTextBox
+ modsDirBrowseBtn
+ lwjglDirTextBox
+ lwjglDirBrowseBtn
+ iconsDirTextBox
+ iconsDirBrowseBtn
+ languageBox
+ resetNotificationsBtn
sortLastLaunchedBtn
sortByNameBtn
+ themeComboBox
jsonEditorTextBox
jsonEditorBrowseBtn
+ autoupdateMinecraft
maximizedCheckBox
windowWidthSpinBox
windowHeightSpinBox
@@ -1076,7 +1111,23 @@
jvmArgsTextBox
preLaunchCmdTextBox
postExitCmdTextBox
- settingsTabs
+ proxyDefaultBtn
+ proxyNoneBtn
+ proxySOCKS5Btn
+ proxyHTTPBtn
+ proxyAddrEdit
+ proxyPortEdit
+ proxyUserEdit
+ proxyPassEdit
+ jprofilerPathEdit
+ jprofilerPathBtn
+ jprofilerCheckBtn
+ jvisualvmPathEdit
+ jvisualvmPathBtn
+ jvisualvmCheckBtn
+ mceditPathEdit
+ mceditPathBtn
+ mceditCheckBtn
diff --git a/logic/BaseVersionList.h b/logic/BaseVersionList.h
index f903b52c9..21b44e8dd 100644
--- a/logic/BaseVersionList.h
+++ b/logic/BaseVersionList.h
@@ -100,10 +100,7 @@ public:
/*!
* Sorts the version list.
*/
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Woverloaded-virtual"
virtual void sort() = 0;
- #pragma clang diagnostic pop
protected
slots:
diff --git a/logic/VersionFilterData.cpp b/logic/VersionFilterData.cpp
index e85230185..866d49470 100644
--- a/logic/VersionFilterData.cpp
+++ b/logic/VersionFilterData.cpp
@@ -65,4 +65,8 @@ VersionFilterData::VersionFilterData()
* (these versions need to be tested by us first)
*/
legacyCutoffDate = timeFromS3Time("2013-06-25T15:08:56+02:00");
+ lwjglWhitelist =
+ QSet{"net.java.jinput:jinput", "net.java.jinput:jinput-platform",
+ "net.java.jutils:jutils", "org.lwjgl.lwjgl:lwjgl",
+ "org.lwjgl.lwjgl:lwjgl_util", "org.lwjgl.lwjgl:lwjgl-platform"};
}
diff --git a/logic/VersionFilterData.h b/logic/VersionFilterData.h
index e010adc7e..98ecb36c3 100644
--- a/logic/VersionFilterData.h
+++ b/logic/VersionFilterData.h
@@ -22,5 +22,7 @@ struct VersionFilterData
QSet legacyBlacklist;
// no new versions below this date will be accepted from Mojang servers
QDateTime legacyCutoffDate;
+ // Libraries that belong to LWJGL
+ QSet lwjglWhitelist;
};
extern VersionFilterData g_VersionFilterData;
diff --git a/logic/forge/ForgeInstaller.cpp b/logic/forge/ForgeInstaller.cpp
index 7ab0a09b7..74db2bfce 100644
--- a/logic/forge/ForgeInstaller.cpp
+++ b/logic/forge/ForgeInstaller.cpp
@@ -133,8 +133,8 @@ bool ForgeInstaller::add(OneSixInstance *to)
int sliding_insert_window = 0;
{
QJsonArray librariesPlus;
- // A blacklist - we ignore these entirely
- QSet blacklist{"lwjgl", "lwjgl_util", "lwjgl-platform"};
+ // A blacklist
+ QSet blacklist{"authlib", "realms"};
//
QList xzlist{"org.scala-lang", "com.typesafe"};
// for each library in the version we are adding (except for the blacklisted)
@@ -143,15 +143,38 @@ bool ForgeInstaller::add(OneSixInstance *to)
QString libName = lib->name();
QString rawName = lib->rawName();
- // ignore blacklisted stuff
+ // ignore lwjgl libraries.
+ if (g_VersionFilterData.lwjglWhitelist.contains(lib->fullname()))
+ 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 (libName.contains("minecraftforge"))
+ if(m_forge_version->type == ForgeVersion::Gradle)
{
- lib->setAbsoluteUrl(m_universal_url);
+ if (libName == "forge")
+ {
+ lib->m_name.setClassifier("universal");
+ lib->finalize();
+ }
+ 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->m_name = spec;
+ lib->finalize();
+ }
+ }
+ else
+ {
+ if (libName.contains("minecraftforge"))
+ {
+ lib->setAbsoluteUrl(m_universal_url);
+ }
}
// WARNING: This could actually break.
@@ -192,7 +215,7 @@ bool ForgeInstaller::add(OneSixInstance *to)
{
// add lib
libObj.insert("insert", QString("prepend"));
- if (lib->name() == "minecraftforge")
+ if (lib->name() == "minecraftforge" || lib->name() == "forge")
{
libObj.insert("MMC-depend", QString("hard"));
}
diff --git a/logic/forge/ForgeVersion.h b/logic/forge/ForgeVersion.h
index 466f46bd1..c7adc5729 100644
--- a/logic/forge/ForgeVersion.h
+++ b/logic/forge/ForgeVersion.h
@@ -17,6 +17,13 @@ struct ForgeVersion : public BaseVersion
QString filename();
QString url();
+ enum
+ {
+ Invalid,
+ Legacy,
+ Gradle
+ } type = Invalid;
+
bool usesInstaller();
int m_buildnr = 0;
diff --git a/logic/forge/ForgeVersionList.cpp b/logic/forge/ForgeVersionList.cpp
index efb30ba6f..ee7c63e31 100644
--- a/logic/forge/ForgeVersionList.cpp
+++ b/logic/forge/ForgeVersionList.cpp
@@ -286,6 +286,7 @@ bool ForgeListLoadTask::parseForgeList(QList &out)
fVersion->installer_filename = installer_filename;
fVersion->universal_filename = universal_filename;
fVersion->m_buildnr = build_nr;
+ fVersion->type = ForgeVersion::Legacy;
out.append(fVersion);
}
}
@@ -335,6 +336,10 @@ bool ForgeListLoadTask::parseForgeGradleList(QList &out)
QJsonObject number = it.value().toObject();
std::shared_ptr fVersion(new ForgeVersion());
fVersion->m_buildnr = number.value("build").toDouble();
+ if(fVersion->m_buildnr >= 953 && fVersion->m_buildnr <= 965)
+ {
+ QLOG_DEBUG() << fVersion->m_buildnr;
+ }
fVersion->jobbuildver = number.value("version").toString();
fVersion->branch = number.value("branch").toString("");
fVersion->mcver = number.value("mcversion").toString();
@@ -395,6 +400,7 @@ bool ForgeListLoadTask::parseForgeGradleList(QList &out)
}
fVersion->universal_filename = universal_filename;
fVersion->installer_filename = installer_filename;
+ fVersion->type = ForgeVersion::Gradle;
out.append(fVersion);
}
return true;
diff --git a/logic/liteloader/LiteLoaderVersionList.cpp b/logic/liteloader/LiteLoaderVersionList.cpp
index eced78e97..af8509d6f 100644
--- a/logic/liteloader/LiteLoaderVersionList.cpp
+++ b/logic/liteloader/LiteLoaderVersionList.cpp
@@ -212,7 +212,7 @@ void LLListLoadTask::listDownloaded()
{
auto lib = RawLibrary::fromJson(libobject, "versions.json");
// hack to make liteloader 1.7.10_00 work
- if(lib->m_name == "org.ow2.asm:asm-all:5.0.3")
+ if(lib->m_name == GradleSpecifier("org.ow2.asm:asm-all:5.0.3"))
{
lib->m_base_url = "http://repo.maven.apache.org/maven2/";
}
diff --git a/logic/minecraft/GradleSpecifier.h b/logic/minecraft/GradleSpecifier.h
index 3ee40b864..8a02e4d9e 100644
--- a/logic/minecraft/GradleSpecifier.h
+++ b/logic/minecraft/GradleSpecifier.h
@@ -30,13 +30,13 @@ struct GradleSpecifier
QRegExp matcher("([^:@]+):([^:@]+):([^:@]+)" "(:([^:@]+))?" "(@([^:@]+))?");
m_valid = matcher.exactMatch(value);
auto elements = matcher.capturedTexts();
- groupId = elements[1];
- artifactId = elements[2];
- version = elements[3];
- classifier = elements[5];
+ m_groupId = elements[1];
+ m_artifactId = elements[2];
+ m_version = elements[3];
+ m_classifier = elements[5];
if(!elements[7].isEmpty())
{
- extension = elements[7];
+ m_extension = elements[7];
}
return *this;
}
@@ -44,14 +44,14 @@ struct GradleSpecifier
{
if(!m_valid)
return "INVALID";
- QString retval = groupId + ":" + artifactId + ":" + version;
- if(!classifier.isEmpty())
+ QString retval = m_groupId + ":" + m_artifactId + ":" + m_version;
+ if(!m_classifier.isEmpty())
{
- retval += ":" + classifier;
+ retval += ":" + m_classifier;
}
- if(extension.isExplicit())
+ if(m_extension.isExplicit())
{
- retval += "@" + extension;
+ retval += "@" + m_extension;
}
return retval;
}
@@ -59,25 +59,71 @@ struct GradleSpecifier
{
if(!m_valid)
return "INVALID";
- QString path = groupId;
+ QString path = m_groupId;
path.replace('.', '/');
- path += '/' + artifactId + '/' + version + '/' + artifactId + '-' + version;
- if(!classifier.isEmpty())
+ path += '/' + m_artifactId + '/' + m_version + '/' + m_artifactId + '-' + m_version;
+ if(!m_classifier.isEmpty())
{
- path += "-" + classifier;
+ path += "-" + m_classifier;
}
- path += "." + extension;
+ path += "." + m_extension;
return path;
}
- bool valid()
+ inline bool valid() const
{
return m_valid;
}
+ inline QString version() const
+ {
+ return m_version;
+ }
+ inline QString groupId() const
+ {
+ return m_groupId;
+ }
+ inline QString artifactId() const
+ {
+ return m_artifactId;
+ }
+ inline void setClassifier(const QString & classifier)
+ {
+ m_classifier = classifier;
+ }
+ inline QString classifier() const
+ {
+ return m_classifier;
+ }
+ inline QString extension() const
+ {
+ return m_extension;
+ }
+ inline QString artifactPrefix() const
+ {
+ return m_groupId + ":" + m_artifactId;
+ }
+ bool matchName(const GradleSpecifier & other)
+ {
+ return other.artifactId() == artifactId() && other.groupId() == groupId();
+ }
+ bool operator==(const GradleSpecifier & other)
+ {
+ if(m_groupId != other.m_groupId)
+ return false;
+ if(m_artifactId != other.m_artifactId)
+ return false;
+ if(m_version != other.m_version)
+ return false;
+ if(m_classifier != other.m_classifier)
+ return false;
+ if(m_extension != other.m_extension)
+ return false;
+ return true;
+ }
private:
- QString groupId;
- QString artifactId;
- QString version;
- QString classifier;
- DefaultVariable extension = DefaultVariable("jar");
+ QString m_groupId;
+ QString m_artifactId;
+ QString m_version;
+ QString m_classifier;
+ DefaultVariable m_extension = DefaultVariable("jar");
bool m_valid = false;
};
diff --git a/logic/minecraft/MinecraftVersion.cpp b/logic/minecraft/MinecraftVersion.cpp
index 488a180a2..8368c4302 100644
--- a/logic/minecraft/MinecraftVersion.cpp
+++ b/logic/minecraft/MinecraftVersion.cpp
@@ -2,6 +2,8 @@
#include "InstanceVersion.h"
#include "VersionBuildError.h"
#include "VersionBuilder.h"
+#include "MultiMC.h"
+#include "logic/settings/SettingsObject.h"
bool MinecraftVersion::usesLegacyLauncher()
{
@@ -141,3 +143,15 @@ QString MinecraftVersion::getPatchFilename()
{
return QString();
}
+
+bool MinecraftVersion::needsUpdate()
+{
+ auto settings = MMC->settings();
+ bool result = hasUpdate() && settings->get("AutoUpdateMinecraftVersions").toBool();
+ return result;
+}
+
+bool MinecraftVersion::hasUpdate()
+{
+ return m_versionSource == Remote || (m_versionSource == Local && upstreamUpdate);
+}
diff --git a/logic/minecraft/MinecraftVersion.h b/logic/minecraft/MinecraftVersion.h
index 82073a974..e06dadb1a 100644
--- a/logic/minecraft/MinecraftVersion.h
+++ b/logic/minecraft/MinecraftVersion.h
@@ -45,14 +45,8 @@ public: /* methods */
virtual QString getPatchVersion() override;
virtual QString getPatchName() override;
virtual QString getPatchFilename() override;
- bool needsUpdate()
- {
- return m_versionSource == Remote;
- }
- bool hasUpdate()
- {
- return m_versionSource == Remote || (m_versionSource == Local && upstreamUpdate);
- }
+ bool needsUpdate();
+ bool hasUpdate();
private: /* methods */
void applyFileTo(InstanceVersion *version);
diff --git a/logic/minecraft/MinecraftVersionList.cpp b/logic/minecraft/MinecraftVersionList.cpp
index 3aa1ac012..ee2285283 100644
--- a/logic/minecraft/MinecraftVersionList.cpp
+++ b/logic/minecraft/MinecraftVersionList.cpp
@@ -266,7 +266,8 @@ void MinecraftVersionList::loadMojangList(QJsonDocument jsonDoc, VersionSource s
QString versionTypeStr = versionObj.value("type").toString("");
if (versionTypeStr.isEmpty())
{
- // FIXME: log this somewhere
+ QLOG_ERROR() << "Ignoring" << versionID
+ << "because it doesn't have the version type set.";
continue;
}
// OneSix or Legacy. use filter to determine type
@@ -284,10 +285,13 @@ void MinecraftVersionList::loadMojangList(QJsonDocument jsonDoc, VersionSource s
}
else
{
- // FIXME: log this somewhere
+ QLOG_ERROR() << "Ignoring" << versionID
+ << "because it has an invalid version type.";
continue;
}
mcVersion->m_type = versionTypeStr;
+ QLOG_INFO() << "Loaded version" << versionID << "from"
+ << ((source == Remote) ? "remote" : "local") << "version list.";
tempList.append(mcVersion);
}
updateListData(tempList);
@@ -333,12 +337,6 @@ void MinecraftVersionList::updateListData(QList versions)
{
continue;
}
- // is it actually an update?
- if (orig->m_updateTime >= added->m_updateTime)
- {
- // nope.
- continue;
- }
// alright, it's an update. put it inside the original, for further processing.
orig->upstreamUpdate = added;
}
@@ -451,13 +449,10 @@ void MCVListVersionUpdateTask::json_downloaded()
}
QList filteredLibs;
QList lwjglLibs;
- QSet lwjglFilter = {
- "net.java.jinput:jinput", "net.java.jinput:jinput-platform",
- "net.java.jutils:jutils", "org.lwjgl.lwjgl:lwjgl",
- "org.lwjgl.lwjgl:lwjgl_util", "org.lwjgl.lwjgl:lwjgl-platform"};
+
for (auto lib : file->overwriteLibs)
{
- if (lwjglFilter.contains(lib->fullname()))
+ if (g_VersionFilterData.lwjglWhitelist.contains(lib->fullname()))
{
lwjglLibs.append(lib);
}
@@ -581,9 +576,11 @@ void MinecraftVersionList::finalizeUpdate(QString version)
auto updatedVersion = std::dynamic_pointer_cast(m_vlist[idx]);
+ // reject any updates to builtin versions.
if (updatedVersion->m_versionSource == Builtin)
return;
+ // if we have an update for the version, replace it, make the update local
if (updatedVersion->upstreamUpdate)
{
auto updatedWith = updatedVersion->upstreamUpdate;
@@ -593,6 +590,7 @@ void MinecraftVersionList::finalizeUpdate(QString version)
}
else
{
+ // otherwise, just set the version as local;
updatedVersion->m_versionSource = Local;
}
diff --git a/logic/minecraft/OneSixLibrary.cpp b/logic/minecraft/OneSixLibrary.cpp
index f9a274bdc..c562f3530 100644
--- a/logic/minecraft/OneSixLibrary.cpp
+++ b/logic/minecraft/OneSixLibrary.cpp
@@ -30,7 +30,7 @@ OneSixLibrary::OneSixLibrary(RawLibraryPtr base)
m_hint = base->m_hint;
m_absolute_url = base->m_absolute_url;
extract_excludes = base->extract_excludes;
- m_native_suffixes = base->m_native_suffixes;
+ m_native_classifiers = base->m_native_classifiers;
m_rules = base->m_rules;
finalize();
}
@@ -42,34 +42,8 @@ OneSixLibraryPtr OneSixLibrary::fromRawLibrary(RawLibraryPtr lib)
void OneSixLibrary::finalize()
{
- QStringList parts = m_name.split(':');
- QString relative = parts[0];
- relative.replace('.', '/');
- relative += '/' + parts[1] + '/' + parts[2] + '/' + parts[1] + '-' + parts[2];
-
- if (!isNative())
- relative += ".jar";
- else
- {
- if (m_native_suffixes.contains(currentSystem))
- {
- relative += "-" + m_native_suffixes[currentSystem] + ".jar";
- }
- else
- {
- // really, bad.
- relative += ".jar";
- }
- }
-
- m_decentname = parts[1];
- m_decentversion = minVersion = parts[2];
- m_storage_path = relative;
- if(m_base_url.isEmpty())
- m_download_url = QString("https://" + URLConstants::LIBRARY_BASE) + relative;
- else
- m_download_url = m_base_url + relative;
-
+ QString relative;
+
if (m_rules.empty())
{
m_is_active = true;
@@ -87,13 +61,32 @@ void OneSixLibrary::finalize()
}
if (isNative())
{
- m_is_active = m_is_active && m_native_suffixes.contains(currentSystem);
+ GradleSpecifier nativeSpec = m_name;
+ m_is_active = m_is_active && m_native_classifiers.contains(currentSystem);
m_decenttype = "Native";
+ if(m_native_classifiers.contains(currentSystem))
+ {
+ nativeSpec.setClassifier(m_native_classifiers[currentSystem]);
+ }
+ else
+ {
+ nativeSpec.setClassifier("INVALID");
+ }
+ relative = nativeSpec.toPath();
}
else
{
+ relative = m_name.toPath();
m_decenttype = "Java";
}
+
+ m_decentname = m_name.artifactId();
+ m_decentversion = minVersion = m_name.version();
+ m_storage_path = relative;
+ if(m_base_url.isEmpty())
+ m_download_url = QString("https://" + URLConstants::LIBRARY_BASE) + relative;
+ else
+ m_download_url = m_base_url + relative;
}
void OneSixLibrary::setName(const QString &name)
@@ -106,11 +99,11 @@ void OneSixLibrary::setBaseUrl(const QString &base_url)
}
void OneSixLibrary::addNative(OpSys os, const QString &suffix)
{
- m_native_suffixes[os] = suffix;
+ m_native_classifiers[os] = suffix;
}
void OneSixLibrary::clearSuffixes()
{
- m_native_suffixes.clear();
+ m_native_classifiers.clear();
}
void OneSixLibrary::setRules(QList> rules)
{
diff --git a/logic/minecraft/RawLibrary.cpp b/logic/minecraft/RawLibrary.cpp
index 3351268a5..76bd72607 100644
--- a/logic/minecraft/RawLibrary.cpp
+++ b/logic/minecraft/RawLibrary.cpp
@@ -54,7 +54,7 @@ RawLibraryPtr RawLibrary::fromJson(const QJsonObject &libObj, const QString &fil
OpSys opSys = OpSys_fromString(it.key());
if (opSys != Os_Other)
{
- out->m_native_suffixes[opSys] = it.value().toString();
+ out->m_native_classifiers[opSys] = it.value().toString();
}
}
}
@@ -134,13 +134,13 @@ RawLibraryPtr RawLibrary::fromJsonPlus(const QJsonObject &libObj, const QString
bool RawLibrary::isNative() const
{
- return m_native_suffixes.size() != 0;
+ return m_native_classifiers.size() != 0;
}
QJsonObject RawLibrary::toJson()
{
QJsonObject libRoot;
- libRoot.insert("name", m_name);
+ libRoot.insert("name", (QString)m_name);
if (m_absolute_url.size())
libRoot.insert("MMC-absoluteUrl", m_absolute_url);
if (m_hint.size())
@@ -154,8 +154,8 @@ QJsonObject RawLibrary::toJson()
if (isNative())
{
QJsonObject nativeList;
- auto iter = m_native_suffixes.begin();
- while (iter != m_native_suffixes.end())
+ auto iter = m_native_classifiers.begin();
+ while (iter != m_native_classifiers.end())
{
nativeList.insert(OpSys_toString(iter.key()), iter.value());
iter++;
@@ -188,18 +188,5 @@ QJsonObject RawLibrary::toJson()
QString RawLibrary::fullname()
{
- QStringList parts = m_name.split(':');
- return parts[0] + ":" + parts[1];
-}
-
-QString RawLibrary::group()
-{
- QStringList parts = m_name.split(':');
- return parts[0];
-}
-
-QString RawLibrary::version()
-{
- QStringList parts = m_name.split(':');
- return parts[2];
+ return m_name.artifactPrefix();
}
diff --git a/logic/minecraft/RawLibrary.h b/logic/minecraft/RawLibrary.h
index 583c34d2c..6e8f7f10c 100644
--- a/logic/minecraft/RawLibrary.h
+++ b/logic/minecraft/RawLibrary.h
@@ -8,6 +8,7 @@
#include "logic/minecraft/OneSixRule.h"
#include "logic/minecraft/OpSys.h"
+#include "GradleSpecifier.h"
#include "logic/net/URLConstants.h"
class RawLibrary;
@@ -23,11 +24,9 @@ public: /* methods */
QJsonObject toJson();
QString fullname();
- QString version();
- QString group();
public: /* data */
- QString m_name;
+ GradleSpecifier m_name;
QString m_base_url;
/// type hint - modifies how the library is treated
@@ -41,7 +40,7 @@ public: /* data */
/// Returns true if the library is native
bool isNative() const;
/// native suffixes per OS
- QMap m_native_suffixes;
+ QMap m_native_classifiers;
bool applyRules = false;
QList> m_rules;
diff --git a/logic/minecraft/VersionFile.cpp b/logic/minecraft/VersionFile.cpp
index 93f57116e..600c71ae2 100644
--- a/logic/minecraft/VersionFile.cpp
+++ b/logic/minecraft/VersionFile.cpp
@@ -17,13 +17,13 @@ using namespace MMCJson;
#define CURRENT_MINIMUM_LAUNCHER_VERSION 14
-int findLibrary(QList haystack, const QString &needle)
+int findLibraryByName(QList haystack, const GradleSpecifier &needle)
{
int retval = -1;
for (int i = 0; i < haystack.size(); ++i)
{
- QString chunk = haystack.at(i)->rawName();
- if (QRegExp(needle, Qt::CaseSensitive, QRegExp::WildcardUnix).indexIn(chunk) != -1)
+
+ if(haystack.at(i)->m_name.matchName(needle))
{
// only one is allowed.
if (retval != -1)
@@ -382,7 +382,7 @@ void VersionFile::applyTo(InstanceVersion *version)
case RawLibrary::Apply:
{
// QLOG_INFO() << "Applying lib " << lib->name;
- int index = findLibrary(version->libraries, lib->m_name);
+ int index = findLibraryByName(version->libraries, lib->m_name);
if (index >= 0)
{
auto library = version->libraries[index];
@@ -405,7 +405,7 @@ void VersionFile::applyTo(InstanceVersion *version)
if (lib->isNative())
{
// library->clearSuffixes();
- library->m_native_suffixes = lib->m_native_suffixes;
+ library->m_native_classifiers = lib->m_native_classifiers;
/*
for (auto native : lib->natives)
{
@@ -429,9 +429,7 @@ void VersionFile::applyTo(InstanceVersion *version)
case RawLibrary::Prepend:
{
// QLOG_INFO() << "Adding lib " << lib->name;
- const int startOfVersion = lib->m_name.lastIndexOf(':') + 1;
- const int index = findLibrary(
- version->libraries, QString(lib->m_name).replace(startOfVersion, INT_MAX, '*'));
+ const int index = findLibraryByName(version->libraries, lib->m_name);
if (index < 0)
{
if (lib->insertType == RawLibrary::Append)
@@ -446,8 +444,8 @@ void VersionFile::applyTo(InstanceVersion *version)
else
{
auto otherLib = version->libraries.at(index);
- const Util::Version ourVersion = lib->m_name.mid(startOfVersion, INT_MAX);
- const Util::Version otherVersion = otherLib->version();
+ const Util::Version ourVersion = lib->m_name.version();
+ const Util::Version otherVersion = otherLib->m_name.version();
// if the existing version is a hard dependency we can either use it or
// fail, but we can't change it
if (otherLib->dependType == OneSixLibrary::Hard)
@@ -497,16 +495,17 @@ void VersionFile::applyTo(InstanceVersion *version)
}
case RawLibrary::Replace:
{
- QString toReplace;
+ GradleSpecifier toReplace;
if (lib->insertData.isEmpty())
{
- const int startOfVersion = lib->m_name.lastIndexOf(':') + 1;
- toReplace = QString(lib->m_name).replace(startOfVersion, INT_MAX, '*');
+ toReplace = lib->m_name;
}
else
+ {
toReplace = lib->insertData;
+ }
// QLOG_INFO() << "Replacing lib " << toReplace << " with " << lib->name;
- int index = findLibrary(version->libraries, toReplace);
+ int index = findLibraryByName(version->libraries, toReplace);
if (index >= 0)
{
version->libraries.replace(index, OneSixLibrary::fromRawLibrary(lib));
@@ -521,7 +520,7 @@ void VersionFile::applyTo(InstanceVersion *version)
}
for (auto lib : removeLibs)
{
- int index = findLibrary(version->libraries, lib);
+ int index = findLibraryByName(version->libraries, lib);
if (index >= 0)
{
// QLOG_INFO() << "Removing lib " << lib;