Check for outdated Java versions older than 16

This commit is contained in:
Camotoy 2021-07-23 19:51:46 -04:00
parent 070ff46558
commit f16f91f469
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
2 changed files with 32 additions and 1 deletions

View file

@ -379,9 +379,40 @@ public class GeyserConnector {
logger.warning(LanguageUtils.getLocaleStringLog("geyser.core.movement_warn"));
}
checkForOutdatedJava();
newsHandler.handleNews(null, NewsItemAction.ON_SERVER_STARTED);
}
private void checkForOutdatedJava() {
final int supportedJavaVersion = 16;
// Taken from Paper
String javaVersion = System.getProperty("java.version");
Matcher matcher = Pattern.compile("(?:1\\.)?(\\d+)").matcher(javaVersion);
if (!matcher.find()) {
getLogger().debug("Could not parse Java version string " + javaVersion);
return;
}
String version = matcher.group(1);
int majorVersion;
try {
majorVersion = Integer.parseInt(version);
} catch (NumberFormatException e) {
getLogger().debug("Could not format as an int: " + version);
return;
}
if (majorVersion < supportedJavaVersion) {
getLogger().warning("*********************************************");
getLogger().warning("");
getLogger().warning(LanguageUtils.getLocaleStringLog("geyser.bootstrap.unsupported_java.header"));
getLogger().warning(LanguageUtils.getLocaleStringLog("geyser.bootstrap.unsupported_java.message", supportedJavaVersion, javaVersion));
getLogger().warning("");
getLogger().warning("*********************************************");
}
}
public void shutdown() {
bootstrap.getGeyserLogger().info(LanguageUtils.getLocaleStringLog("geyser.core.shutdown"));
shuttingDown = true;

@ -1 +1 @@
Subproject commit c8923b1f71c7f66621729be47dec7f911606c6a1
Subproject commit d0cbd4b616be6c057115fdb13d75866b8452893e