2020-12-03 07:27:03 +01:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Kyle Wood <demonwav@gmail.com>
|
|
|
|
Date: Wed, 2 Dec 2020 21:58:45 -0800
|
|
|
|
Subject: [PATCH] Add warning for servers not running on Java 11
|
|
|
|
|
|
|
|
|
2020-12-05 04:58:24 +01:00
|
|
|
diff --git a/src/main/java/io/papermc/paper/util/PaperJvmChecker.java b/src/main/java/io/papermc/paper/util/PaperJvmChecker.java
|
2020-12-03 07:27:03 +01:00
|
|
|
new file mode 100644
|
2020-12-05 04:58:24 +01:00
|
|
|
index 0000000000000000000000000000000000000000..c6ea429819c07e7f4bc257cad73463a030767825
|
2020-12-03 07:27:03 +01:00
|
|
|
--- /dev/null
|
2020-12-05 04:58:24 +01:00
|
|
|
+++ b/src/main/java/io/papermc/paper/util/PaperJvmChecker.java
|
|
|
|
@@ -0,0 +1,48 @@
|
|
|
|
+package io.papermc.paper.util;
|
2020-12-03 07:27:03 +01:00
|
|
|
+
|
|
|
|
+import org.apache.logging.log4j.LogManager;
|
|
|
|
+import org.apache.logging.log4j.Logger;
|
|
|
|
+
|
2020-12-05 04:58:24 +01:00
|
|
|
+import java.util.regex.Matcher;
|
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
+
|
2020-12-05 00:57:46 +01:00
|
|
|
+public class PaperJvmChecker {
|
2020-12-03 07:27:03 +01:00
|
|
|
+
|
2020-12-05 00:57:46 +01:00
|
|
|
+ private static int getJvmVersion() {
|
|
|
|
+ String javaVersion = System.getProperty("java.version");
|
2020-12-05 04:58:24 +01:00
|
|
|
+ final Matcher matcher = Pattern.compile("(?:1\\.)?(\\d+)").matcher(javaVersion);
|
|
|
|
+ if (!matcher.find()) {
|
|
|
|
+ LogManager.getLogger().warn("Failed to determine Java version; Could not parse: {}", javaVersion);
|
|
|
|
+ return -1;
|
2020-12-03 07:27:03 +01:00
|
|
|
+ }
|
|
|
|
+
|
2020-12-05 04:58:24 +01:00
|
|
|
+ final String version = matcher.group(1);
|
2020-12-03 07:27:03 +01:00
|
|
|
+ try {
|
2020-12-05 00:57:46 +01:00
|
|
|
+ return Integer.parseInt(version);
|
2020-12-03 07:27:03 +01:00
|
|
|
+ } catch (final NumberFormatException e) {
|
2020-12-05 04:58:24 +01:00
|
|
|
+ LogManager.getLogger().warn("Failed to determine Java version; Could not parse {} from {}", version, javaVersion, e);
|
2020-12-05 00:57:46 +01:00
|
|
|
+ return -1;
|
2020-12-03 07:27:03 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2020-12-05 00:57:46 +01:00
|
|
|
+ public static void checkJvm() {
|
|
|
|
+ if (getJvmVersion() < 11) {
|
|
|
|
+ final Logger logger = LogManager.getLogger();
|
|
|
|
+ logger.warn("************************************************************");
|
|
|
|
+ logger.warn("* WARNING - YOU ARE RUNNING AN OUTDATED VERSION OF JAVA.");
|
|
|
|
+ logger.warn("* PAPER WILL STOP BEING COMPATIBLE WITH THIS VERSION OF");
|
|
|
|
+ logger.warn("* JAVA WHEN MINECRAFT 1.17 IS RELEASED.");
|
|
|
|
+ logger.warn("*");
|
|
|
|
+ logger.warn("* Please update the version of Java you use to run Paper");
|
|
|
|
+ logger.warn("* to at least Java 11. When Paper for Minecraft 1.17 is");
|
|
|
|
+ logger.warn("* released support for versions of Java before 11 will");
|
|
|
|
+ logger.warn("* be dropped.");
|
|
|
|
+ logger.warn("*");
|
|
|
|
+ logger.warn("* Current Java version: {}", System.getProperty("java.version"));
|
|
|
|
+ logger.warn("*");
|
|
|
|
+ logger.warn("* Check this forum post for more information: ");
|
|
|
|
+ logger.warn("* https://papermc.io/java11");
|
|
|
|
+ logger.warn("************************************************************");
|
|
|
|
+ }
|
2020-12-03 07:27:03 +01:00
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2021-05-02 21:37:24 +02:00
|
|
|
index 43b713476c6f841aafaac9f2a1216b937261efc2..07021c760b0d734b91240ca96c6480be469a1005 100644
|
2020-12-03 07:27:03 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2021-03-16 16:50:45 +01:00
|
|
|
@@ -181,6 +181,7 @@ import org.bukkit.event.server.ServerLoadEvent;
|
2021-03-09 00:12:31 +01:00
|
|
|
|
2020-12-05 04:58:24 +01:00
|
|
|
import co.aikar.timings.MinecraftTimings; // Paper
|
|
|
|
import org.spigotmc.SlackActivityAccountant; // Spigot
|
2021-03-09 00:12:31 +01:00
|
|
|
+import io.papermc.paper.util.PaperJvmChecker; // Paper
|
2020-12-05 04:58:24 +01:00
|
|
|
|
|
|
|
public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTask> implements IMojangStatistics, ICommandListener, AutoCloseable {
|
2021-03-09 00:12:31 +01:00
|
|
|
|
2021-04-16 02:47:34 +02:00
|
|
|
@@ -1075,6 +1076,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
2020-12-03 07:27:03 +01:00
|
|
|
LOGGER.info("Done ({})! For help, type \"help\"", doneTime);
|
|
|
|
// Paper end
|
|
|
|
|
2020-12-05 04:58:24 +01:00
|
|
|
+ PaperJvmChecker.checkJvm(); // Paper jvm version nag
|
2020-12-03 07:27:03 +01:00
|
|
|
org.spigotmc.WatchdogThread.tick(); // Paper
|
|
|
|
org.spigotmc.WatchdogThread.hasStarted = true; // Paper
|
|
|
|
Arrays.fill( recentTps, 20 );
|