mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 23:10:16 +01:00
Also load resources from LibraryLoader (#8335)
This commit is contained in:
parent
ede4468516
commit
ad4ca0a429
2 changed files with 49 additions and 0 deletions
|
@ -49,4 +49,5 @@ Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
|||
LemonCaramel <admin@caramel.moe>
|
||||
Noah van der Aa <ndvdaa@gmail.com>
|
||||
Doc <nachito94@msn.com>
|
||||
Nick Hensel <nickhensel25@icloud.com>
|
||||
```
|
||||
|
|
48
patches/api/Also-load-resources-from-LibraryLoader.patch
Normal file
48
patches/api/Also-load-resources-from-LibraryLoader.patch
Normal file
|
@ -0,0 +1,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 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<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
|
||||
+
|
||||
@Override
|
||||
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
|
||||
return loadClass0(name, resolve, true, true);
|
Loading…
Reference in a new issue