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

folia-supported not seems to work #22

Closed EpiCanard closed 1 year ago

EpiCanard commented 1 year ago

Hello,

Since I migrated my server to Paper 1.20 I have the following error :

[Server] WARN [ScalaLoader] Plugin MapSaver has not explicitly declared it supports the Folia api
[Server] WARN [ScalaLoader] Skipping loading plugin plugins/ScalaLoader/scalaplugins/MapSaver-1.0.3.jar.

I saw you added support of Folia in ScalaLoader, so I added folia-supported: false in my plugin.yml but I still have the issue.

Thanks in advance for your help

Jannyboy11 commented 1 year ago

Right, ScalaLoader's Folia detection method checks for certain classes to be present on the server. Paper 1.20 added the RegionScheduler api from Folia to Paper, hence it breaks. The fix is to check for a class that is only present in the Folia server (and not in the Folia api), so I will get right to it.

Jannyboy11 commented 1 year ago

Should be fixed as of https://github.com/Jannyboy11/ScalaPluginLoader/commit/13cbe4c4ad0251a699bf1a9dea6e057b12ed99fe, released in https://github.com/Jannyboy11/ScalaPluginLoader/releases/tag/v0.18.8. No release yet on SpigotMC because I couldn't test it yet myself.

EpiCanard commented 1 year ago

Thank you, I will test this today and give you feedback

Jannyboy11 commented 1 year ago

CI has just finished, download is available.

Jannyboy11 commented 1 year ago

Tested it, confirmed that the fix works with my example plugins, but with your MapSaver I get the following errors (I might need to update it though):

[11:04:45 ERROR]: [org.bukkit.craftbukkit.v1_20_R1.CraftServer] The permission mapsaver.commands.update is already defined! loading MapSaver v0.0.0+99-7be1df72 (Is it up to date?)
java.lang.IllegalArgumentException: The permission mapsaver.commands.update is already defined!
        at io.papermc.paper.plugin.manager.PaperPermissionManager.addPermission(PaperPermissionManager.java:56) ~[paper-1.20.1.jar:git-Paper-95]
        at io.papermc.paper.plugin.manager.PaperPermissionManager.addPermissions(PaperPermissionManager.java:46) ~[paper-1.20.1.jar:git-Paper-95]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.addPermissions(PaperPluginManagerImpl.java:213) ~[paper-1.20.1.jar:git-Paper-95]
        at org.bukkit.craftbukkit.v1_20_R1.CraftServer.enablePlugin(CraftServer.java:637) ~[paper-1.20.1.jar:git-Paper-95]
        at org.bukkit.craftbukkit.v1_20_R1.CraftServer.enablePlugins(CraftServer.java:550) ~[paper-1.20.1.jar:git-Paper-95]
        at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:636) ~[paper-1.20.1.jar:git-Paper-95]
        at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:435) ~[paper-1.20.1.jar:git-Paper-95]
        at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:308) ~[paper-1.20.1.jar:git-Paper-95]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1101) ~[paper-1.20.1.jar:git-Paper-95]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318) ~[paper-1.20.1.jar:git-Paper-95]
        at java.lang.Thread.run(Thread.java:1623) ~[?:?]
[11:04:45 INFO]: [MapSaver] Enabling MapSaver v0.0.0+99-7be1df72
[11:04:48 ERROR]: Error occurred while enabling MapSaver v0.0.0+99-7be1df72 (Is it up to date?)
java.lang.NoSuchMethodError: org.yaml.snakeyaml.constructor.SafeConstructor: method 'void <init>()' not found
        at io.circe.yaml.parser.package$FlatteningConstructor.<init>(package.scala:41) ~[?:?]
        at io.circe.yaml.parser.package$.yamlToJson(package.scala:53) ~[?:?]
        at io.circe.yaml.parser.package$.$anonfun$parse$1(package.scala:20) ~[?:?]
        at scala.util.Either.flatMap(Either.scala:352) ~[?:?]
        at io.circe.yaml.parser.package$.parse(package.scala:19) ~[?:?]
        at io.circe.yaml.parser.package$.parse(package.scala:23) ~[?:?]
        at fr.epicanard.mapsaver.resources.ResourceLoader$.parseContent(ResourceLoader.scala:35) ~[MapSaver-0.0.0+99-7be1df72.jar:?]
        at fr.epicanard.mapsaver.resources.ResourceLoader$.$anonfun$loadFromPath$1(ResourceLoader.scala:27) ~[MapSaver-0.0.0+99-7be1df72.jar:?]
        at scala.util.Success.flatMap(Try.scala:258) ~[?:?]
        at fr.epicanard.mapsaver.resources.ResourceLoader$.loadFromPath(ResourceLoader.scala:26) ~[MapSaver-0.0.0+99-7be1df72.jar:?]
        at fr.epicanard.mapsaver.resources.ResourceLoader$.extractAndLoadResource(ResourceLoader.scala:21) ~[MapSaver-0.0.0+99-7be1df72.jar:?]
        at fr.epicanard.mapsaver.MapSaverPlugin$.initPlugin(MapSaverPlugin.scala:39) ~[MapSaver-0.0.0+99-7be1df72.jar:?]
        at fr.epicanard.mapsaver.MapSaverPlugin$.onEnable(MapSaverPlugin.scala:31) ~[MapSaver-0.0.0+99-7be1df72.jar:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:281) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:189) ~[paper-1.20.1.jar:git-Paper-95]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:104) ~[paper-1.20.1.jar:git-Paper-95]
        at xyz.janboerman.scalaloader.paper.ScalaLoader.enableScalaPlugins(ScalaLoader.java:368) ~[ScalaLoader-0.18.8-SNAPSHOT.jar:?]
        at xyz.janboerman.scalaloader.paper.ScalaLoader.onServerLoad(ScalaLoader.java:173) ~[ScalaLoader-0.18.8-SNAPSHOT.jar:?]
        at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor1.execute(Unknown Source) ~[?:?]
        at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:77) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:81) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:git-Paper-95]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54) ~[paper-1.20.1.jar:git-Paper-95]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:126) ~[paper-1.20.1.jar:git-Paper-95]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:615) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:637) ~[paper-1.20.1.jar:git-Paper-95]
        at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:435) ~[paper-1.20.1.jar:git-Paper-95]
        at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:308) ~[paper-1.20.1.jar:git-Paper-95]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1101) ~[paper-1.20.1.jar:git-Paper-95]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318) ~[paper-1.20.1.jar:git-Paper-95]

I think the 2nd issue is caused by your plugin using SnakeYaml from the server, so you will have to relocate your SnakeYaml dependency (or upgrade to the same version as the server, perhaps this can be done by upgrading Circe). I am not sure about the first issue.

EpiCanard commented 1 year ago

I think your analyze is right. Maybe a conflict with the version of snakeyaml used by Circe and the one used by spigot.

Jannyboy11 commented 1 year ago

I am not sure whether the first exception is a bug in ScalaLoader, in Paper or in MapSaver. I need more time to investigate it.

EpiCanard commented 1 year ago

When I update circe-yaml to 0.15.0-RC1 (use snakeyaml 2.0 like paper) the second error disappear and all work as expected with the plugin.

The first error still persist even if it doesn't seem to impact the load of plugins.

Maybe the plugin is loaded two times ? I don't know why it trigger this permission specifically because it's not the only permission I use

Jannyboy11 commented 1 year ago

Maybe the plugin is loaded two times ?

I don't know yet for sure, but something like that is happening indeed. At least I know the permissions are added to the server twice. I need to do more investigation as to what causes this. My assumption right now is it is a behavioural change by Paper again that caused it. I might have some time to investigate it tonight, but otherwise it'll be somewhere later this week.

Jannyboy11 commented 1 year ago

After some debug logging in the Paper codebase, I can confirm that MapSaver isn't being enabled twice. It's just enabled once at PluginLoadOrder.POSTWORLD.

Jannyboy11 commented 1 year ago

Paper did a change that caused the CraftServer to enable plugins that in the past were only enabled by ScalaLoader. I still have to work out a solution.

EpiCanard commented 1 year ago

Again 😩 So when you register a plugin it is automatically enabled by paper ?

Jannyboy11 commented 1 year ago

ScalaLoader loads ScalaPlugins during its own onLoad() phase. If during this phase ScalaPlugins are added to Paper's plugin instance manager, then CraftServer will pick up on them when the 'enabling' phase begins.

I think it an be fixed by delaying the registration till after ScalaLoader's onLoad has finishes if the ScalaPlugin's load order is PluginLoadTyoe.POSTWORLD, but I will have to do some more testing tomorrow. Specifically I will need to test whether ScalaPlugins with either load type (STARTUP or POSTWORLD) will still load and enable correctly.

Jannyboy11 commented 1 year ago

Fixed as of https://github.com/Jannyboy11/ScalaPluginLoader/releases/v0.18.9

EpiCanard commented 1 year ago

Thanks a lot for your work !