Events/Java/minified-java

EnsureJavaVersionEvent

Called when the Java version requestedMajorVersion must be ensured before the game can launch.

Not called if the requested version (or a higher compatible one) is already installed.

Fields

requestedMajorVersionint

The major Java version required to launch the game

Accessor: requestedMajorVersion()

When it fires

JavaManager.ensureJavaVersion(requiredMajorVersion) first checks the JVM Minified itself is running on. If that JVM's major version already satisfies requiredMajorVersion, this event never fires and the current JVM is reused to launch the game - no separate runtime is downloaded. It only fires once your running JVM is too old for the target Minecraft version, right before Minified looks for (or downloads) a matching managed runtime under its runtime install root.

Launcher.launchMinecraft(...) calls this indirectly via JavaManager.getRequiredJavaVersion(versionJson), unless you set LaunchConfiguration.customJavaExecutable - in that case Minified skips Java resolution entirely and none of the Java events fire.

Listening

Subscribe on the EventBus the event is posted to, see Events for which bus that is.

eventBus.subscribe(EnsureJavaVersionEvent.class, event -> {
    int requestedMajorVersion = event.requestedMajorVersion();
});

Posted by

API reference: com.dervarex.minified.java.events.EnsureJavaVersionEvent