parent
31a6e3f898
commit
f15abda562
2 changed files with 61 additions and 38 deletions
|
@ -0,0 +1,30 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Kyle Wood <demonwav@gmail.com>
|
||||
Date: Fri, 4 Dec 2020 15:53:19 -0800
|
||||
Subject: [PATCH] Enable multi-release plugin jars
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
index 62f7a6817da079513f471e36cd79739d36a36d86..7760be3e34fa20825faf145d9fb5b2855c1a4602 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
@@ -56,7 +56,18 @@ public final class PluginClassLoader extends URLClassLoader { // Spigot
|
||||
this.description = description;
|
||||
this.dataFolder = dataFolder;
|
||||
this.file = file;
|
||||
- this.jar = new JarFile(file);
|
||||
+ // Paper - enable multi-release jars for Java 9+
|
||||
+ JarFile jarFile;
|
||||
+ try {
|
||||
+ final java.lang.reflect.Method runtimeVersionMethod = JarFile.class.getMethod("runtimeVersion");
|
||||
+ final Object runtimeVersion = runtimeVersionMethod.invoke(null);
|
||||
+ @SuppressWarnings("JavaReflectionMemberAccess") final java.lang.reflect.Constructor<JarFile> constructor = JarFile.class.getConstructor(File.class, boolean.class, int.class, runtimeVersion.getClass());
|
||||
+ jarFile = constructor.newInstance(file, true, java.util.zip.ZipFile.OPEN_READ, runtimeVersion);
|
||||
+ } catch (Exception ignored) {
|
||||
+ jarFile = new JarFile(file);
|
||||
+ }
|
||||
+ this.jar = jarFile;
|
||||
+ // Paper end
|
||||
this.manifest = jar.getManifest();
|
||||
this.url = file.toURI().toURL();
|
||||
|
|
@ -6,49 +6,41 @@ Subject: [PATCH] Add warning for servers not running on Java 11
|
|||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/util/PaperJvmChecker.java b/src/main/java/com/destroystokyo/paper/util/PaperJvmChecker.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..023123d52fbb458e6ee2d38e42c9651a5c7be728
|
||||
index 0000000000000000000000000000000000000000..afe07487b1e7337293f7147619a6f10fcdef9d0e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/util/PaperJvmChecker.java
|
||||
@@ -0,0 +1,56 @@
|
||||
@@ -0,0 +1,49 @@
|
||||
+package com.destroystokyo.paper.util;
|
||||
+
|
||||
+import org.apache.logging.log4j.LogManager;
|
||||
+import org.apache.logging.log4j.Logger;
|
||||
+
|
||||
+public final class PaperJvmChecker {
|
||||
+public class PaperJvmChecker {
|
||||
+
|
||||
+ private PaperJvmChecker() {}
|
||||
+
|
||||
+ public static void checkJvm() {
|
||||
+ final Logger logger = LogManager.getLogger();
|
||||
+
|
||||
+ final String javaVersion = System.getProperty("java.version");
|
||||
+ final int dotIndex = javaVersion.indexOf('.');
|
||||
+ private static int getJvmVersion() {
|
||||
+ String javaVersion = System.getProperty("java.version");
|
||||
+ int dotIndex = javaVersion.indexOf('.');
|
||||
+
|
||||
+ if (javaVersion.startsWith("1.")) {
|
||||
+ // definitely old
|
||||
+ PaperJvmChecker.printWarning(javaVersion, logger);
|
||||
+ return;
|
||||
+ // For Java 8 and below, trim off the 1. prefix
|
||||
+ javaVersion = javaVersion.substring(2);
|
||||
+ dotIndex = javaVersion.indexOf('.');
|
||||
+ }
|
||||
+
|
||||
+ final int endIndex = dotIndex == -1 ? javaVersion.length() : dotIndex;
|
||||
+ final String version = javaVersion.substring(0, endIndex);
|
||||
+
|
||||
+ final int javaVersionNum;
|
||||
+ try {
|
||||
+ javaVersionNum = Integer.parseInt(version);
|
||||
+ return Integer.parseInt(version);
|
||||
+ } catch (final NumberFormatException e) {
|
||||
+ logger.warn("Failed to determine Java version; Could not parse {}", version, e);
|
||||
+ PaperJvmChecker.printWarning(javaVersion, logger);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (javaVersionNum < 11) {
|
||||
+ PaperJvmChecker.printWarning(javaVersion, logger);
|
||||
+ LogManager.getLogger().warn("Failed to determine Java version; Could not parse {}", version, e);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static void printWarning(final String version, final Logger logger) {
|
||||
+ 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");
|
||||
|
@ -59,12 +51,13 @@ index 0000000000000000000000000000000000000000..023123d52fbb458e6ee2d38e42c9651a
|
|||
+ logger.warn("* released support for versions of Java before 11 will");
|
||||
+ logger.warn("* be dropped.");
|
||||
+ logger.warn("*");
|
||||
+ logger.warn("* Current Java version: " + version);
|
||||
+ 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("************************************************************");
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 0108a1a68572df562349688e93f8134cb14d6116..12d781f4ae6a46d0885972035870d5b5b62f5b8b 100644
|
||||
|
|
Loading…
Reference in a new issue