diff --git a/ScalaLoader-Bukkit/src/main/java/xyz/janboerman/scalaloader/plugin/ScalaPlugin.java b/ScalaLoader-Bukkit/src/main/java/xyz/janboerman/scalaloader/plugin/ScalaPlugin.java index 7893ba7f..231c6c6e 100644 --- a/ScalaLoader-Bukkit/src/main/java/xyz/janboerman/scalaloader/plugin/ScalaPlugin.java +++ b/ScalaLoader-Bukkit/src/main/java/xyz/janboerman/scalaloader/plugin/ScalaPlugin.java @@ -400,9 +400,20 @@ public void reloadConfig() { /** * Gets the plugin loader. * @return a {@link ScalaPluginLoader} + * @deprecated use {@link #pluginLoader()} instead. */ + @Deprecated //TODO at the next deprecation clean up spree, make this method final. @Override public ScalaPluginLoader getPluginLoader() { + return pluginLoader(); + } + + /** + * Get the plugin loader. + * @return a {@link ScalaPluginLoader} + */ + @Override + public ScalaPluginLoader pluginLoader() { return pluginLoader; } diff --git a/ScalaLoader-Common/src/main/java/xyz/janboerman/scalaloader/compat/IScalaPlugin.java b/ScalaLoader-Common/src/main/java/xyz/janboerman/scalaloader/compat/IScalaPlugin.java index 920cb632..4750dd39 100644 --- a/ScalaLoader-Common/src/main/java/xyz/janboerman/scalaloader/compat/IScalaPlugin.java +++ b/ScalaLoader-Common/src/main/java/xyz/janboerman/scalaloader/compat/IScalaPlugin.java @@ -62,6 +62,14 @@ public default IScalaPluginClassLoader classLoader() { return (IScalaPluginClassLoader) getClass().getClassLoader(); } + /** + * Get the {@link org.bukkit.plugin.PluginLoader} of this plugin. + * @return the plugin loader + */ + public default IScalaPluginLoader pluginLoader() { + return classLoader().getPluginLoader(); + } + /** * Get the prefix of this plugin, used for logging. * @return the prefix diff --git a/ScalaLoader-Paper/src/main/java/xyz/janboerman/scalaloader/paper/ScalaLoader.java b/ScalaLoader-Paper/src/main/java/xyz/janboerman/scalaloader/paper/ScalaLoader.java index d9c2b80f..1b68929a 100644 --- a/ScalaLoader-Paper/src/main/java/xyz/janboerman/scalaloader/paper/ScalaLoader.java +++ b/ScalaLoader-Paper/src/main/java/xyz/janboerman/scalaloader/paper/ScalaLoader.java @@ -11,6 +11,7 @@ import org.bukkit.event.server.ServerLoadEvent; import org.bukkit.event.server.ServerLoadEvent.LoadType; import org.bukkit.plugin.PluginLoadOrder; +import org.bukkit.plugin.UnknownDependencyException; import org.bukkit.plugin.java.JavaPlugin; import org.objectweb.asm.ClassReader; import org.yaml.snakeyaml.Yaml; @@ -286,6 +287,7 @@ private void loadScalaPlugins(File[] files) { File file = byName.get(pluginName); PluginJarScanResult scanResult = scanResults.get(file); ScalaPluginDescription description = descriptions.get(file); + //TODO check dependencies. if not available, might want to try to load the ScalaPlugin again once Paper's own JavaPlugin loading process has finished. ScalaPluginProviderContext context = new ScalaPluginProviderContext(file, description); var optionalBootstrap = getBootstrap(description, descriptionPlugins.get(file).descriptionClassLoader()); diff --git a/ScalaLoader-Paper/src/main/java/xyz/janboerman/scalaloader/paper/plugin/ScalaPlugin.java b/ScalaLoader-Paper/src/main/java/xyz/janboerman/scalaloader/paper/plugin/ScalaPlugin.java index aa7a5c9a..98c9c27f 100644 --- a/ScalaLoader-Paper/src/main/java/xyz/janboerman/scalaloader/paper/plugin/ScalaPlugin.java +++ b/ScalaLoader-Paper/src/main/java/xyz/janboerman/scalaloader/paper/plugin/ScalaPlugin.java @@ -59,6 +59,11 @@ public ScalaPluginClassLoader classLoader() { return (ScalaPluginClassLoader) super.getClassLoader(); } + @Override + public ScalaPluginLoader pluginLoader() { + return (ScalaPluginLoader) classLoader().getPluginLoader(); + } + /** {@inheritDoc} */ @Override public File getConfigFile() { diff --git a/ScalaLoader-Paper/src/main/java/xyz/janboerman/scalaloader/paper/transform/MainClassCallerMigrator.java b/ScalaLoader-Paper/src/main/java/xyz/janboerman/scalaloader/paper/transform/MainClassCallerMigrator.java index 09b2fbf4..9701479b 100644 --- a/ScalaLoader-Paper/src/main/java/xyz/janboerman/scalaloader/paper/transform/MainClassCallerMigrator.java +++ b/ScalaLoader-Paper/src/main/java/xyz/janboerman/scalaloader/paper/transform/MainClassCallerMigrator.java @@ -22,6 +22,8 @@ public MethodVisitor visitMethod(int access, String name, String descriptor, Str public void visitMethodInsn(int opcode, String owner, String name, String descriptor, boolean isInterface) { if (asmMainClassName.equals(owner) && name.equals("getClassLoader")) { super.visitMethodInsn(opcode, asmMainClassName, "classLoader", descriptor, isInterface); + } else if (asmMainClassName.equals(owner) && name.equals("getPluginLoader")) { + super.visitMethodInsn(opcode, asmMainClassName, "pluginLoader", descriptor, isInterface); } else { super.visitMethodInsn(opcode, owner, name, descriptor, isInterface); }