Merge branch 'MultiMC-develop' into develop

This commit is contained in:
Sebastian-byte
2021-06-25 18:47:00 -05:00
16 changed files with 116 additions and 14 deletions

View File

@@ -256,6 +256,8 @@ set(MINECRAFT_SOURCES
minecraft/launch/ScanModFolders.h
minecraft/launch/InjectAuthlib.cpp
minecraft/launch/InjectAuthlib.h
minecraft/launch/VerifyJavaInstall.cpp
minecraft/launch/VerifyJavaInstall.h
minecraft/legacy/LegacyModList.h
minecraft/legacy/LegacyModList.cpp

View File

@@ -24,6 +24,7 @@
#include "minecraft/launch/ReconstructAssets.h"
#include "minecraft/launch/ScanModFolders.h"
#include "minecraft/launch/InjectAuthlib.h"
#include "minecraft/launch/VerifyJavaInstall.h"
#include "java/launch/CheckJava.h"
#include "java/JavaUtils.h"
#include "meta/Index.h"
@@ -751,7 +752,7 @@ MessageLevel::Enum MinecraftInstance::guessLevel(const QString &line, MessageLev
|| line.contains(QRegularExpression("Caused by: " + javaSymbol))
|| line.contains(QRegularExpression("([a-zA-Z_$][a-zA-Z\\d_$]*\\.)+[a-zA-Z_$]?[a-zA-Z\\d_$]*(Exception|Error|Throwable)"))
|| line.contains(QRegularExpression("... \\d+ more$"))
)
)
return MessageLevel::Error;
return level;
}
@@ -923,6 +924,11 @@ shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPt
process->appendStep(new ReconstructAssets(pptr));
}
// verify that minimum Java requirements are met
{
process->appendStep(new VerifyJavaInstall(pptr));
}
// authlib patch
if (session->m_accountPtr->provider()->injectorEndpoint() != "")
{

View File

@@ -65,4 +65,7 @@ VersionFilterData::VersionFilterData()
QSet<QString>{"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"};
java8BeginsDate = timeFromS3Time("2017-03-30T09:32:19+00:00");
java16BeginsDate = timeFromS3Time("2021-05-12T11:19:15+00:00");
}

View File

@@ -23,5 +23,9 @@ struct VersionFilterData
QDateTime legacyCutoffDate;
// Libraries that belong to LWJGL
QSet<QString> lwjglWhitelist;
// release date of first version to require Java 8 (17w13a)
QDateTime java8BeginsDate;
// release data of first version to require Java 16 (21w19a)
QDateTime java16BeginsDate;
};
extern VersionFilterData MULTIMC_LOGIC_EXPORT g_VersionFilterData;

View File

@@ -0,0 +1,34 @@
#include "VerifyJavaInstall.h"
#include <launch/LaunchTask.h>
#include <minecraft/MinecraftInstance.h>
#include <minecraft/PackProfile.h>
#include <minecraft/VersionFilterData.h>
void VerifyJavaInstall::executeTask() {
auto m_inst = std::dynamic_pointer_cast<MinecraftInstance>(m_parent->instance());
auto javaVersion = m_inst->getJavaVersion();
auto minecraftComponent = m_inst->getPackProfile()->getComponent("net.minecraft");
// Java 16 requirement
if (minecraftComponent->getReleaseDateTime() >= g_VersionFilterData.java16BeginsDate) {
if (javaVersion.major() < 16) {
emit logLine("Minecraft 21w19a and above require the use of Java 16",
MessageLevel::Fatal);
emitFailed(tr("Minecraft 21w19a and above require the use of Java 16"));
return;
}
}
// Java 8 requirement
else if (minecraftComponent->getReleaseDateTime() >= g_VersionFilterData.java8BeginsDate) {
if (javaVersion.major() < 8) {
emit logLine("Minecraft 17w13a and above require the use of Java 8",
MessageLevel::Fatal);
emitFailed(tr("Minecraft 17w13a and above require the use of Java 8"));
return;
}
}
emitSucceeded();
}

View File

@@ -0,0 +1,17 @@
#pragma once
#include <launch/LaunchStep.h>
class VerifyJavaInstall : public LaunchStep {
Q_OBJECT
public:
explicit VerifyJavaInstall(LaunchTask *parent) : LaunchStep(parent) {
};
~VerifyJavaInstall() override = default;
void executeTask() override;
bool canAbort() const override {
return false;
}
};

View File

@@ -4,6 +4,7 @@
#include <MMCZip.h>
#include <minecraft/OneSixVersionFormat.h>
#include <Version.h>
#include <net/ChecksumValidator.h>
#include "ATLPackInstallTask.h"
#include "BuildConfig.h"
@@ -407,7 +408,12 @@ void PackInstallTask::installConfigs()
auto entry = ENV.metacache()->resolveEntry("ATLauncherPacks", path);
entry->setStale(true);
jobPtr->addNetAction(Net::Download::makeCached(url, entry));
auto dl = Net::Download::makeCached(url, entry);
if (!m_version.configs.sha1.isEmpty()) {
auto rawSha1 = QByteArray::fromHex(m_version.configs.sha1.toLatin1());
dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawSha1));
}
jobPtr->addNetAction(dl);
archivePath = entry->getFullPath();
connect(jobPtr.get(), &NetJob::succeeded, this, [&]()
@@ -508,6 +514,10 @@ void PackInstallTask::downloadMods()
modsToExtract.insert(entry->getFullPath(), mod);
auto dl = Net::Download::makeCached(url, entry);
if (!mod.md5.isEmpty()) {
auto rawMd5 = QByteArray::fromHex(mod.md5.toLatin1());
dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Md5, rawMd5));
}
jobPtr->addNetAction(dl);
}
else if(mod.type == ModType::Decomp) {
@@ -516,6 +526,10 @@ void PackInstallTask::downloadMods()
modsToDecomp.insert(entry->getFullPath(), mod);
auto dl = Net::Download::makeCached(url, entry);
if (!mod.md5.isEmpty()) {
auto rawMd5 = QByteArray::fromHex(mod.md5.toLatin1());
dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Md5, rawMd5));
}
jobPtr->addNetAction(dl);
}
else {
@@ -526,6 +540,10 @@ void PackInstallTask::downloadMods()
entry->setStale(true);
auto dl = Net::Download::makeCached(url, entry);
if (!mod.md5.isEmpty()) {
auto rawMd5 = QByteArray::fromHex(mod.md5.toLatin1());
dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Md5, rawMd5));
}
jobPtr->addNetAction(dl);
auto path = FS::PathCombine(m_stagingPath, "minecraft", relpath, mod.file);

View File

@@ -109,6 +109,11 @@ static void loadVersionLibrary(ATLauncher::VersionLibrary & p, QJsonObject & obj
p.server = Json::ensureString(obj, "server", "");
}
static void loadVersionConfigs(ATLauncher::VersionConfigs & p, QJsonObject & obj) {
p.filesize = Json::requireInteger(obj, "filesize");
p.sha1 = Json::requireString(obj, "sha1");
}
static void loadVersionMod(ATLauncher::VersionMod & p, QJsonObject & obj) {
p.name = Json::requireString(obj, "name");
p.version = Json::requireString(obj, "version");
@@ -195,7 +200,6 @@ void ATLauncher::loadVersion(PackVersion & v, QJsonObject & obj)
}
}
if(obj.contains("mods")) {
auto mods = Json::requireArray(obj, "mods");
for (const auto modRaw : mods)
@@ -206,4 +210,9 @@ void ATLauncher::loadVersion(PackVersion & v, QJsonObject & obj)
v.mods.append(mod);
}
}
if(obj.contains("configs")) {
auto configsObj = Json::requireObject(obj, "configs");
loadVersionConfigs(v.configs, configsObj);
}
}

View File

@@ -101,6 +101,12 @@ struct VersionMod
bool effectively_hidden;
};
struct VersionConfigs
{
int filesize;
QString sha1;
};
struct PackVersion
{
QString version;
@@ -112,6 +118,7 @@ struct PackVersion
VersionLoader loader;
QVector<VersionLibrary> libraries;
QVector<VersionMod> mods;
VersionConfigs configs;
};
MULTIMC_LOGIC_EXPORT void loadVersion(PackVersion & v, QJsonObject & obj);

View File

@@ -37,8 +37,8 @@ JavaPage::JavaPage(QWidget *parent) : QWidget(parent), ui(new Ui::JavaPage)
ui->setupUi(this);
ui->tabWidget->tabBar()->hide();
auto sysMB = Sys::getSystemRam() / Sys::megabyte;
ui->maxMemSpinBox->setMaximum(sysMB);
auto sysMiB = Sys::getSystemRam() / Sys::mebibyte;
ui->maxMemSpinBox->setMaximum(sysMiB);
loadSettings();
}

View File

@@ -51,7 +51,7 @@
<string>The maximum amount of memory Minecraft is allowed to use.</string>
</property>
<property name="suffix">
<string notr="true"> MB</string>
<string notr="true"> MiB</string>
</property>
<property name="minimum">
<number>128</number>
@@ -87,7 +87,7 @@
<string>The amount of memory Minecraft is started with.</string>
</property>
<property name="suffix">
<string notr="true"> MB</string>
<string notr="true"> MiB</string>
</property>
<property name="minimum">
<number>128</number>
@@ -116,7 +116,7 @@
<string>The amount of memory available to store loaded Java classes.</string>
</property>
<property name="suffix">
<string notr="true"> MB</string>
<string notr="true"> MiB</string>
</property>
<property name="minimum">
<number>64</number>

View File

@@ -19,7 +19,7 @@ InstanceSettingsPage::InstanceSettingsPage(BaseInstance *inst, QWidget *parent)
{
m_settings = inst->settings();
ui->setupUi(this);
auto sysMB = Sys::getSystemRam() / Sys::megabyte;
auto sysMB = Sys::getSystemRam() / Sys::mebibyte;
ui->maxMemSpinBox->setMaximum(sysMB);
connect(ui->openGlobalJavaSettingsButton, &QCommandLinkButton::clicked, this, &InstanceSettingsPage::globalSettingsButtonClicked);
connect(MMC, &MultiMC::globalSettingsAboutToOpen, this, &InstanceSettingsPage::applySettings);

View File

@@ -116,7 +116,7 @@
<string>The maximum amount of memory Minecraft is allowed to use.</string>
</property>
<property name="suffix">
<string notr="true"> MB</string>
<string notr="true"> MiB</string>
</property>
<property name="minimum">
<number>128</number>
@@ -138,7 +138,7 @@
<string>The amount of memory Minecraft is started with.</string>
</property>
<property name="suffix">
<string notr="true"> MB</string>
<string notr="true"> MiB</string>
</property>
<property name="minimum">
<number>128</number>
@@ -160,7 +160,7 @@
<string>The amount of memory available to store loaded Java classes.</string>
</property>
<property name="suffix">
<string notr="true"> MB</string>
<string notr="true"> MiB</string>
</property>
<property name="minimum">
<number>64</number>

View File

@@ -200,6 +200,8 @@ AtlOptionalModDialog::AtlOptionalModDialog(QWidget *parent, QVector<ATLauncher::
listModel, &AtlOptionalModListModel::selectRecommended);
connect(ui->clearAllButton, &QPushButton::pressed,
listModel, &AtlOptionalModListModel::clearAll);
connect(ui->installButton, &QPushButton::pressed,
this, &QDialog::close);
}
AtlOptionalModDialog::~AtlOptionalModDialog() {

View File

@@ -19,7 +19,7 @@
JavaSettingsWidget::JavaSettingsWidget(QWidget* parent) : QWidget(parent)
{
m_availableMemory = Sys::getSystemRam() / Sys::megabyte;
m_availableMemory = Sys::getSystemRam() / Sys::mebibyte;
goodIcon = MMC->getThemedIcon("status-good");
yellowIcon = MMC->getThemedIcon("status-yellow");

View File

@@ -3,7 +3,7 @@
namespace Sys
{
const uint64_t megabyte = 1024ull * 1024ull;
const uint64_t mebibyte = 1024ull * 1024ull;
struct KernelInfo
{
QString kernelName;