Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-26 16:12:46 +01:00
Warn on outdated Java version
Dieser Commit ist enthalten in:
Ursprung
6da8d5e7be
Commit
a0b63abc6e
@ -540,6 +540,8 @@ public class GeyserImpl implements GeyserApi {
|
|||||||
if (config.isNotifyOnNewBedrockUpdate()) {
|
if (config.isNotifyOnNewBedrockUpdate()) {
|
||||||
VersionCheckUtils.checkForGeyserUpdate(this::getLogger);
|
VersionCheckUtils.checkForGeyserUpdate(this::getLogger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VersionCheckUtils.checkForOutdatedJava(logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,9 +42,12 @@ import javax.annotation.Nonnull;
|
|||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public final class VersionCheckUtils {
|
public final class VersionCheckUtils {
|
||||||
private static @Nonnull OptionalInt LATEST_BEDROCK_RELEASE = OptionalInt.empty();
|
private static @Nonnull OptionalInt LATEST_BEDROCK_RELEASE = OptionalInt.empty();
|
||||||
|
private static final int SUPPORTED_JAVA_VERSION = 17;
|
||||||
|
|
||||||
public static void checkForOutdatedFloodgate(GeyserLogger logger) {
|
public static void checkForOutdatedFloodgate(GeyserLogger logger) {
|
||||||
try {
|
try {
|
||||||
@ -57,6 +60,34 @@ public final class VersionCheckUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void checkForOutdatedJava(GeyserLogger logger) {
|
||||||
|
// Taken from Paper
|
||||||
|
String javaVersion = System.getProperty("java.version");
|
||||||
|
Matcher matcher = Pattern.compile("(?:1\\.)?(\\d+)").matcher(javaVersion);
|
||||||
|
if (!matcher.find()) {
|
||||||
|
logger.debug("Could not parse Java version string " + javaVersion);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String version = matcher.group(1);
|
||||||
|
int majorVersion;
|
||||||
|
try {
|
||||||
|
majorVersion = Integer.parseInt(version);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
logger.debug("Could not format as an int: " + version);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (majorVersion < SUPPORTED_JAVA_VERSION) {
|
||||||
|
logger.warning("*********************************************");
|
||||||
|
logger.warning("");
|
||||||
|
logger.warning(GeyserLocale.getLocaleStringLog("geyser.bootstrap.unsupported_java.header"));
|
||||||
|
logger.warning(GeyserLocale.getLocaleStringLog("geyser.bootstrap.unsupported_java.message", SUPPORTED_JAVA_VERSION, javaVersion));
|
||||||
|
logger.warning("");
|
||||||
|
logger.warning("*********************************************");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void checkForGeyserUpdate(Supplier<GeyserCommandSource> recipient) {
|
public static void checkForGeyserUpdate(Supplier<GeyserCommandSource> recipient) {
|
||||||
CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
try {
|
try {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren