Jannyboy11 / ScalaPluginLoader

PluginLoader for Bukkit that provides Scala runtime classes and enhanced APIs.
https://www.spigotmc.org/resources/scalaloader.59568/
GNU Lesser General Public License v3.0
26 stars 10 forks source link

Problems when depending other Java plugins. #8

Closed freeze-dolphin closed 3 years ago

freeze-dolphin commented 3 years ago

Problems

I' am writing a scala plugin using scala.

But it depends some other plugins written in Java.

So my codes come like this:

@Scala(version = ScalaVersion.v2_13_6)
@Api(ApiVersion.v1_16)
object PlugGividado extends ScalaPlugin(
    new ScalaPluginDescription(
        "PlainShop",
        "0.1.0"
    ).addHardDepend("RedLib").addHardDepend("Vault")) {
...
}

However, while starting the server, it logs:

[12:32:42] [Server thread/INFO]: [ScalaLoader] Loading ScalaLoader v0.17.1-SNAPSHOT
[12:32:42] [Server thread/INFO]: [ScalaLoader] Loading Scala 2.13.6 libraries from disk
[12:32:42] [Server thread/ERROR]: Could not load 'plugins\ScalaLoader\scalaplugins\plain-shop.jar' in folder 'plugins\ScalaLoader\scalaplugins'
org.bukkit.plugin.UnknownDependencyException: Unknown/missing dependency plugins: [RedLib, Vault]. Please download and install these plugins to run 'PlainShop'.
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:291) ~[patched_1.16.5.jar:git-Paper-778]
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:120) ~[patched_1.16.5.jar:git-Paper-778]
    at xyz.janboerman.scalaloader.ScalaLoader.onLoad(ScalaLoader.java:120) ~[?:?]
    at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:399) ~[patched_1.16.5.jar:git-Paper-778]
    at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:269) ~[patched_1.16.5.jar:git-Paper-778]
    at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1069) ~[patched_1.16.5.jar:git-Paper-778]
    at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-778]
    at java.lang.Thread.run(Thread.java:831) [?:?]

I noticed that this message was above the message of loading 'RedLib' or 'Vault', it seemed that there were some problems in plugins ordering.

I am sure that I've put 'RedLib' and 'Vault' into my 'plugins/' folder.

Jannyboy11 commented 3 years ago

Ahh.. I see what is going on here. ScalaLoader gives the order to Bukkit's pluginmanager to load the scala plugins in its plugins folder from ScalaLoader's own onLoad method. ScalaLoader itself however could already have been loaded before RedLib and Vault are loaded, so that's why you're seeing this.

I have to think of a good solution to fix this, but in the mean time you can use .addSoftDepend instead of .addHardDepend.

Current fixes that cross my mind:

I think the second one is the better solution but I want to give this a bit more thought and headspace before I do it. It'll take a bit of time to implement too.

Jannyboy11 commented 3 years ago

Fixed as of https://github.com/Jannyboy11/ScalaPluginLoader/commit/259b7a762f3ab63ddd0db8c3b3a07e44cbee7ec0