From ad4ca0a4298928a18d7daf4290b569102f872b74 Mon Sep 17 00:00:00 2001 From: Nick Hensel <47005420+Goldmensch@users.noreply.github.com> Date: Tue, 20 Sep 2022 03:07:03 +0200 Subject: [PATCH] Also load resources from LibraryLoader (#8335) --- LICENSE.md | 1 + ...so-load-resources-from-LibraryLoader.patch | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 patches/api/Also-load-resources-from-LibraryLoader.patch diff --git a/LICENSE.md b/LICENSE.md index 6bd7bdc0c3..7995d18c5a 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -49,4 +49,5 @@ Owen1212055 <23108066+Owen1212055@users.noreply.github.com> LemonCaramel Noah van der Aa Doc +Nick Hensel ``` diff --git a/patches/api/Also-load-resources-from-LibraryLoader.patch b/patches/api/Also-load-resources-from-LibraryLoader.patch new file mode 100644 index 0000000000..8457d39fe3 --- /dev/null +++ b/patches/api/Also-load-resources-from-LibraryLoader.patch @@ -0,0 +1,48 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Nick Hensel +Date: Sun, 28 Aug 2022 23:44:18 +0200 +Subject: [PATCH] Also load resources from LibraryLoader + + +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 + + @Override + public URL getResource(String name) { +- return findResource(name); ++ // Paper start ++ URL resource = findResource(name); ++ if (resource == null && libraryLoader != null) { ++ return libraryLoader.getResource(name); ++ } ++ return resource; ++ // Paper end + } + + @Override + public Enumeration getResources(String name) throws IOException { +- return findResources(name); ++ // Paper start ++ java.util.ArrayList resources = new java.util.ArrayList<>(); ++ addEnumeration(resources, findResources(name)); ++ if (libraryLoader != null) { ++ addEnumeration(resources, libraryLoader.getResources(name)); ++ } ++ return Collections.enumeration(resources); ++ // Paper end + } + ++ // Paper start ++ private void addEnumeration(java.util.ArrayList list, Enumeration enumeration) { ++ while (enumeration.hasMoreElements()) { ++ list.add(enumeration.nextElement()); ++ } ++ } ++ // Paper end ++ + @Override + protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { + return loadClass0(name, resolve, true, true);