NOISSUE Fail launch if minimum Java requirement is not met
This will fail launch in the following conditions: 1. A version greater than or equal to Minecraft 17w13a, and less than 21w19a - and the Java version is less than 8. 2. A version greater than or equal to Minecraft 21w19a - and the Java version is less than 16.
This commit is contained in:
parent
7c0fdaa730
commit
a20a7e987f
@ -246,6 +246,8 @@ set(MINECRAFT_SOURCES
|
||||
minecraft/launch/ReconstructAssets.h
|
||||
minecraft/launch/ScanModFolders.cpp
|
||||
minecraft/launch/ScanModFolders.h
|
||||
minecraft/launch/VerifyJavaInstall.cpp
|
||||
minecraft/launch/VerifyJavaInstall.h
|
||||
|
||||
minecraft/legacy/LegacyModList.h
|
||||
minecraft/legacy/LegacyModList.cpp
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "minecraft/launch/ClaimAccount.h"
|
||||
#include "minecraft/launch/ReconstructAssets.h"
|
||||
#include "minecraft/launch/ScanModFolders.h"
|
||||
#include "minecraft/launch/VerifyJavaInstall.h"
|
||||
#include "java/launch/CheckJava.h"
|
||||
#include "java/JavaUtils.h"
|
||||
#include "meta/Index.h"
|
||||
@ -915,6 +916,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));
|
||||
}
|
||||
|
||||
{
|
||||
// actually launch the game
|
||||
auto method = launchMethod();
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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;
|
||||
|
34
api/logic/minecraft/launch/VerifyJavaInstall.cpp
Normal file
34
api/logic/minecraft/launch/VerifyJavaInstall.cpp
Normal 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();
|
||||
}
|
17
api/logic/minecraft/launch/VerifyJavaInstall.h
Normal file
17
api/logic/minecraft/launch/VerifyJavaInstall.h
Normal 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;
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user