diff options
author | Jamie Mansfield <jmansfield@cadixdev.org> | 2021-06-23 21:24:25 +0100 |
---|---|---|
committer | Jamie Mansfield <jmansfield@cadixdev.org> | 2021-06-23 21:24:25 +0100 |
commit | a20a7e987fcc6e2d43a1686a175447495245615c (patch) | |
tree | 670eed6bc00107519f73d1ad7b95f46e4d38f6fe /api/logic/minecraft/launch | |
parent | 7c0fdaa7303125b26d0a6882d4616016c3923bca (diff) | |
download | PrismLauncher-a20a7e987fcc6e2d43a1686a175447495245615c.tar.gz PrismLauncher-a20a7e987fcc6e2d43a1686a175447495245615c.tar.bz2 PrismLauncher-a20a7e987fcc6e2d43a1686a175447495245615c.zip |
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.
Diffstat (limited to 'api/logic/minecraft/launch')
-rw-r--r-- | api/logic/minecraft/launch/VerifyJavaInstall.cpp | 34 | ||||
-rw-r--r-- | api/logic/minecraft/launch/VerifyJavaInstall.h | 17 |
2 files changed, 51 insertions, 0 deletions
diff --git a/api/logic/minecraft/launch/VerifyJavaInstall.cpp b/api/logic/minecraft/launch/VerifyJavaInstall.cpp new file mode 100644 index 00000000..657669af --- /dev/null +++ b/api/logic/minecraft/launch/VerifyJavaInstall.cpp @@ -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(); +} diff --git a/api/logic/minecraft/launch/VerifyJavaInstall.h b/api/logic/minecraft/launch/VerifyJavaInstall.h new file mode 100644 index 00000000..a553106d --- /dev/null +++ b/api/logic/minecraft/launch/VerifyJavaInstall.h @@ -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; + } +}; |