Allow using PluginLoader classpath API from Bukkit plugins (#10758)
Allows using the PluginLoader API without any of the other changes imposed by switching to a paper-plugin.yml. Used by setting paper-plugin-loader in plugin.yml to the class name of your PluginLoader. Also allows skipping the libraries field by setting paper-skip-libraries to true (by default both libraries and jars provided by the PluginLoader are added to the classpath).
This commit is contained in:
parent
2a90732677
commit
5e7b65a9a9
3 changed files with 233 additions and 8 deletions
|
@ -877,10 +877,10 @@ index 0000000000000000000000000000000000000000..f9a2c55a354c877749db3f92956de802
|
|||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperPluginClassLoader.java b/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperPluginClassLoader.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..5a00e5c41274ded6b837fb81fa8f54616f2b7bc8
|
||||
index 0000000000000000000000000000000000000000..18401ede9cd1fc7094c6b74859929938e01795ca
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperPluginClassLoader.java
|
||||
@@ -0,0 +1,205 @@
|
||||
@@ -0,0 +1,209 @@
|
||||
+package io.papermc.paper.plugin.entrypoint.classloader;
|
||||
+
|
||||
+import io.papermc.paper.plugin.configuration.PluginMeta;
|
||||
|
@ -936,13 +936,17 @@ index 0000000000000000000000000000000000000000..5a00e5c41274ded6b837fb81fa8f5461
|
|||
+ this.libraryLoader = libraryLoader;
|
||||
+
|
||||
+ this.logger = logger;
|
||||
+ if (this.configuration.hasOpenClassloader()) {
|
||||
+ if (this.configuration().hasOpenClassloader()) {
|
||||
+ this.group = PaperClassLoaderStorage.instance().registerOpenGroup(this);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private PaperPluginMeta configuration() {
|
||||
+ return (PaperPluginMeta) this.configuration;
|
||||
+ }
|
||||
+
|
||||
+ public void refreshClassloaderDependencyTree(DependencyContext dependencyContext) {
|
||||
+ if (this.configuration.hasOpenClassloader()) {
|
||||
+ if (this.configuration().hasOpenClassloader()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ if (this.group != null) {
|
||||
|
@ -1088,13 +1092,13 @@ index 0000000000000000000000000000000000000000..5a00e5c41274ded6b837fb81fa8f5461
|
|||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperSimplePluginClassLoader.java b/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperSimplePluginClassLoader.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..a4c18063854e050bd0c54d488ceeda43c768b6df
|
||||
index 0000000000000000000000000000000000000000..967465e542483e93a736129b5f5c6622cefd33fa
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/plugin/entrypoint/classloader/PaperSimplePluginClassLoader.java
|
||||
@@ -0,0 +1,116 @@
|
||||
+package io.papermc.paper.plugin.entrypoint.classloader;
|
||||
+
|
||||
+import io.papermc.paper.plugin.provider.configuration.PaperPluginMeta;
|
||||
+import io.papermc.paper.plugin.configuration.PluginMeta;
|
||||
+import io.papermc.paper.plugin.util.NamespaceChecker;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+
|
||||
|
@ -1120,13 +1124,13 @@ index 0000000000000000000000000000000000000000..a4c18063854e050bd0c54d488ceeda43
|
|||
+ ClassLoader.registerAsParallelCapable();
|
||||
+ }
|
||||
+
|
||||
+ protected final PaperPluginMeta configuration;
|
||||
+ protected final PluginMeta configuration;
|
||||
+ protected final Path source;
|
||||
+ protected final Manifest jarManifest;
|
||||
+ protected final URL jarUrl;
|
||||
+ protected final JarFile jar;
|
||||
+
|
||||
+ public PaperSimplePluginClassLoader(Path source, JarFile file, PaperPluginMeta configuration, ClassLoader parentLoader) throws IOException {
|
||||
+ public PaperSimplePluginClassLoader(Path source, JarFile file, PluginMeta configuration, ClassLoader parentLoader) throws IOException {
|
||||
+ super(source.getFileName().toString(), new URL[]{source.toUri().toURL()}, parentLoader);
|
||||
+
|
||||
+ this.source = source;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue