Allow Bukkit plugin to use Paper PluginLoader API

This commit is contained in:
Jason Penilla
2024-05-21 13:18:15 -07:00
parent e1b7819229
commit ce6fd58a5e
3 changed files with 49 additions and 12 deletions

View File

@@ -41,15 +41,7 @@ public class PaperClasspathBuilder implements PluginClasspathBuilder {
}
public PaperPluginClassLoader buildClassLoader(Logger logger, Path source, JarFile jarFile, PaperPluginMeta configuration) {
PaperLibraryStore paperLibraryStore = new PaperLibraryStore();
for (ClassPathLibrary library : this.libraries) {
library.register(paperLibraryStore);
}
List<Path> paths = paperLibraryStore.getPaths();
if (PluginInitializerManager.instance().pluginRemapper != null) {
paths = PluginInitializerManager.instance().pluginRemapper.remapLibraries(paths);
}
List<Path> paths = this.buildLibraryPaths(true);
URL[] urls = new URL[paths.size()];
for (int i = 0; i < paths.size(); i++) {
Path path = paths.get(i);
@@ -69,4 +61,17 @@ public class PaperClasspathBuilder implements PluginClasspathBuilder {
throw new RuntimeException(exception);
}
}
public List<Path> buildLibraryPaths(final boolean remap) {
PaperLibraryStore paperLibraryStore = new PaperLibraryStore();
for (ClassPathLibrary library : this.libraries) {
library.register(paperLibraryStore);
}
List<Path> paths = paperLibraryStore.getPaths();
if (remap && PluginInitializerManager.instance().pluginRemapper != null) {
paths = PluginInitializerManager.instance().pluginRemapper.remapLibraries(paths);
}
return paths;
}
}