aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0375-Also-load-resources-from-LibraryLoader.patch
blob: ee5785d8cb6276523b49861123856cc6eedd0e35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Nick Hensel <nickhensel25@icloud.com>
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 b4732c8dd12134a094ef9afc1870077412ce0435..13da387d3b59bc67c0d73e3fbd3a4034b1281527 100644
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
@@ -95,14 +95,35 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
 
     @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<URL> getResources(String name) throws IOException {
-        return findResources(name);
+        // Paper start
+        java.util.ArrayList<URL> 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 <T> void addEnumeration(java.util.ArrayList<T> list, Enumeration<T> enumeration) {
+        while (enumeration.hasMoreElements()) {
+            list.add(enumeration.nextElement());
+        }
+    }
+    // Paper end
+
     // Paper start
     @Override
     public Class<?> loadClass(@NotNull String name, boolean resolve, boolean checkGlobal, boolean checkLibraries) throws ClassNotFoundException {