From 5f6566b549e46032c855d127385d8b1baa8b3c98 Mon Sep 17 00:00:00 2001 From: Emily Date: Sun, 19 Mar 2023 11:50:13 -0300 Subject: [PATCH] Re-enable multi-release plugin JARs (#9001) --- .../Enable-multi-release-plugin-jars.patch | 19 ------------------- patches/api/Paper-Plugins.patch | 4 ++-- ...s-to-contain-the-source-jars-in-stac.patch | 2 +- patches/server/Paper-Plugins.patch | 2 +- 4 files changed, 4 insertions(+), 23 deletions(-) delete mode 100644 patches/api/Enable-multi-release-plugin-jars.patch diff --git a/patches/api/Enable-multi-release-plugin-jars.patch b/patches/api/Enable-multi-release-plugin-jars.patch deleted file mode 100644 index 28fdaef2e6..0000000000 --- a/patches/api/Enable-multi-release-plugin-jars.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Kyle Wood -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 implements io.paperm - this.description = description; - this.dataFolder = dataFolder; - this.file = file; -- this.jar = jarFile == null ? new JarFile(file) : jarFile; // Paper - use JarFile provided by SpigotPluginProvider -+ this.jar = jarFile == null ? new JarFile(file, true, java.util.zip.ZipFile.OPEN_READ, JarFile.runtimeVersion()) : jarFile; // Paper - use JarFile provided by SpigotPluginProvider // Paper - enable multi-release jars for Java 9+ - this.manifest = jar.getManifest(); - this.url = file.toURI().toURL(); - this.libraryLoader = libraryLoader; diff --git a/patches/api/Paper-Plugins.patch b/patches/api/Paper-Plugins.patch index 05a952c351..d4b3dba87f 100644 --- a/patches/api/Paper-Plugins.patch +++ b/patches/api/Paper-Plugins.patch @@ -2067,7 +2067,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - PluginClassLoader(@NotNull final JavaPluginLoader loader, @Nullable final ClassLoader parent, @NotNull final PluginDescriptionFile description, @NotNull final File dataFolder, @NotNull final File file, @Nullable ClassLoader libraryLoader) throws IOException, InvalidPluginException, MalformedURLException { + @org.jetbrains.annotations.ApiStatus.Internal // Paper -+ public PluginClassLoader(@Nullable final ClassLoader parent, @NotNull final PluginDescriptionFile description, @NotNull final File dataFolder, @NotNull final File file, @Nullable ClassLoader libraryLoader, @Nullable JarFile jarFile, io.papermc.paper.plugin.provider.entrypoint.DependencyContext dependencyContext) throws IOException, InvalidPluginException, MalformedURLException { // Paper // Paper - use JarFile provided by SpigotPluginProvider ++ public PluginClassLoader(@Nullable final ClassLoader parent, @NotNull final PluginDescriptionFile description, @NotNull final File dataFolder, @NotNull final File file, @Nullable ClassLoader libraryLoader, JarFile jarFile, io.papermc.paper.plugin.provider.entrypoint.DependencyContext dependencyContext) throws IOException, InvalidPluginException, MalformedURLException { // Paper // Paper - use JarFile provided by SpigotPluginProvider super(new URL[] {file.toURI().toURL()}, parent); - Preconditions.checkArgument(loader != null, "Loader cannot be null"); + this.loader = null; // Paper - pass null into loader field @@ -2077,7 +2077,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.dataFolder = dataFolder; this.file = file; - this.jar = new JarFile(file); -+ this.jar = jarFile == null ? new JarFile(file) : jarFile; // Paper - use JarFile provided by SpigotPluginProvider ++ this.jar = jarFile; // Paper - use JarFile provided by SpigotPluginProvider this.manifest = jar.getManifest(); this.url = file.toURI().toURL(); this.libraryLoader = libraryLoader; diff --git a/patches/api/Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch b/patches/api/Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch index 8fbf4a5b17..d5327035d0 100644 --- a/patches/api/Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch +++ b/patches/api/Rewrite-LogEvents-to-contain-the-source-jars-in-stac.patch @@ -11,7 +11,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm @org.jetbrains.annotations.ApiStatus.Internal // Paper - public PluginClassLoader(@Nullable final ClassLoader parent, @NotNull final PluginDescriptionFile description, @NotNull final File dataFolder, @NotNull final File file, @Nullable ClassLoader libraryLoader, @Nullable JarFile jarFile, io.papermc.paper.plugin.provider.entrypoint.DependencyContext dependencyContext) throws IOException, InvalidPluginException, MalformedURLException { // Paper // Paper - use JarFile provided by SpigotPluginProvider + public PluginClassLoader(@Nullable final ClassLoader parent, @NotNull final PluginDescriptionFile description, @NotNull final File dataFolder, @NotNull final File file, @Nullable ClassLoader libraryLoader, JarFile jarFile, io.papermc.paper.plugin.provider.entrypoint.DependencyContext dependencyContext) throws IOException, InvalidPluginException, MalformedURLException { // Paper // Paper - use JarFile provided by SpigotPluginProvider - super(new URL[] {file.toURI().toURL()}, parent); + super(file.getName(), new URL[] {file.toURI().toURL()}, parent); this.loader = null; // Paper - pass null into loader field diff --git a/patches/server/Paper-Plugins.patch b/patches/server/Paper-Plugins.patch index ebc8c453af..12c586ba07 100644 --- a/patches/server/Paper-Plugins.patch +++ b/patches/server/Paper-Plugins.patch @@ -5069,7 +5069,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + try { + context = this.checkUpdate(context); + -+ JarFile file = new JarFile(context.toFile()); ++ JarFile file = new JarFile(context.toFile(), true, JarFile.OPEN_READ, JarFile.runtimeVersion()); + PluginFileType type = PluginFileType.guessType(file); + if (type == null) { + throw new IllegalArgumentException(source + " is not a valid plugin file, cannot load a plugin from it!");