mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-16 06:30:46 +01:00
parent
256a700c8d
commit
08835cda45
2 changed files with 59 additions and 36 deletions
30
Spigot-API-Patches/Enable-multi-release-plugin-jars.patch
Normal file
30
Spigot-API-Patches/Enable-multi-release-plugin-jars.patch
Normal file
|
@ -0,0 +1,30 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Kyle Wood <kyle@denwav.dev>
|
||||
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
@@ -0,0 +0,0 @@ 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();
|
||||
|
|
@ -15,55 +15,48 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||
+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) {
|
||||
+ 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: " + version);
|
||||
+ logger.warn("*");
|
||||
+ logger.warn("* Check this forum post for more information: ");
|
||||
+ logger.warn("* https://papermc.io/java11");
|
||||
+ logger.warn("************************************************************");
|
||||
+ 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("************************************************************");
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
|
|
Loading…
Reference in a new issue