MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / executeTask

Method executeTask

launcher/minecraft/launch/VerifyJavaInstall.cpp:45–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43#undef minor
44
45void VerifyJavaInstall::executeTask() {
46 auto instance = std::dynamic_pointer_cast<MinecraftInstance>(m_parent->instance());
47 auto packProfile = instance->getPackProfile();
48 auto settings = instance->settings();
49 auto storedVersion = settings->get("JavaVersion").toString();
50 auto ignoreCompatibility = settings->get("IgnoreJavaCompatibility").toBool();
51
52 auto compatibleMajors = packProfile->getProfile()->getCompatibleJavaMajors();
53
54 JavaVersion javaVersion(storedVersion);
55
56 if (compatibleMajors.isEmpty() || compatibleMajors.contains(javaVersion.major()))
57 {
58 emitSucceeded();
59 return;
60 }
61
62
63 if (ignoreCompatibility)
64 {
65 emit logLine(tr("Java major version is incompatible. Things might break."), MessageLevel::Warning);
66 emitSucceeded();
67 return;
68 }
69
70 emit logLine(tr("This instance is not compatible with Java version %1.\n"
71 "Please switch to one of the following Java versions for this instance:").arg(javaVersion.major()),
72 MessageLevel::Error);
73 for (auto major : compatibleMajors)
74 {
75 emit logLine(tr("Java version %1").arg(major), MessageLevel::Error);
76 }
77 emitFailed(QString("Incompatible Java major version"));
78}

Callers

nothing calls this directly

Calls 10

QStringClass · 0.85
getPackProfileMethod · 0.80
getProfileMethod · 0.80
isEmptyMethod · 0.80
majorMethod · 0.80
instanceMethod · 0.45
settingsMethod · 0.45
toStringMethod · 0.45
getMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected