aikar / commands

Java Command Dispatch Framework - (Bukkit, Spigot, Paper, Sponge, Bungee, JDA, Velocity supported, generically usable anywhere)
https://acfspigot.emc.gs
MIT License
566 stars 147 forks source link

Presence of Folia-compatible plugin seems to trip up the Bukkit command manager #394

Closed WasabiThumb closed 1 year ago

WasabiThumb commented 1 year ago

Posting here on behalf of the user who created this issue in my plugin XClaim.

According to this user, when XClaim is present (a folia compatible plugin), he gets errors from ACF's BukkitCommandManager failing to link in folia-exclusive scheduler methods.

Here is a copy of the stack trace they provided:

[06:26:51 INFO]: [SkinsRestorer] Enabling SkinsRestorer v14.2.12
[06:26:51 INFO]: [SkinsRestorer] Detected Minecraft v1_20_R1, using MappingSpigotSkinRefresher.
[06:26:52 ERROR]: Error occurred while enabling SkinsRestorer v14.2.12 (Is it up to date?)
java.lang.NoSuchMethodError: 'io.papermc.paper.threadedregions.scheduler.AsyncScheduler org.bukkit.Bukkit.getAsyncScheduler()'
        at net.skinsrestorer.shadow.aikar.commands.ACFFoliaScheduler.createLocaleTask(ACFFoliaScheduler.java:51) ~[SkinsRestorer.jar:?]
        at net.skinsrestorer.shadow.aikar.commands.BukkitCommandManager.<init>(BukkitCommandManager.java:132) ~[SkinsRestorer.jar:?]
        at net.skinsrestorer.shadow.aikar.commands.PaperCommandManager.<init>(PaperCommandManager.java:34) ~[SkinsRestorer.jar:?]
        at net.skinsrestorer.bukkit.SkinsRestorerBukkit.createCommandManager(SkinsRestorerBukkit.java:488) ~[SkinsRestorer.jar:?]
        at net.skinsrestorer.shared.plugin.SkinsRestorerShared.sharedInitCommands(SkinsRestorerShared.java:70) ~[SkinsRestorer.jar:?]
        at net.skinsrestorer.bukkit.SkinsRestorerBukkit.initCommands(SkinsRestorerBukkit.java:330) ~[SkinsRestorer.jar:?]
        at net.skinsrestorer.bukkit.SkinsRestorerBukkit.pluginStartup(SkinsRestorerBukkit.java:243) ~[SkinsRestorer.jar:?]
        at net.skinsrestorer.bukkit.SkinsRestorerBootstrap.onEnable(SkinsRestorerBootstrap.java:31) ~[SkinsRestorer.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-31]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:104) ~[paper-1.20.1.jar:git-Paper-31]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:507) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_20_R1.CraftServer.enablePlugin(CraftServer.java:566) ~[paper-1.20.1.jar:git-Paper-31]
        at org.bukkit.craftbukkit.v1_20_R1.CraftServer.enablePlugins(CraftServer.java:477) ~[paper-1.20.1.jar:git-Paper-31]
        at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:636) ~[paper-1.20.1.jar:git-Paper-31]
        at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:435) ~[paper-1.20.1.jar:git-Paper-31]
        at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:308) ~[paper-1.20.1.jar:git-Paper-31]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1101) ~[paper-1.20.1.jar:git-Paper-31]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318) ~[paper-1.20.1.jar:git-Paper-31]        at java.lang.Thread.run(Thread.java:833) ~[?:?]

This is probably because of this bit of code here in BukkitCommandManager:

        //See what schedule we should use, bukkit or folia
        try {
            Class.forName("io.papermc.paper.threadedregions.scheduler.AsyncScheduler");
            this.scheduler = new ACFFoliaScheduler();
        } catch (ClassNotFoundException ignored) {
            this.scheduler = new ACFBukkitScheduler();
        }

This is the same method I used to use for Folia detection, however it was falsely identifying Folia on 1.20, so instead I switched to searching for the RegionizedServer class as per advice from PaperMC devs. If I recall correctly, Paper is planning on adding the AsyncScheduler to the base distribution instead of just in Folia. See my implementation here.

chickeneer commented 1 year ago

I have deployed a fix for this that should fix the issue for anyone using ACF Paper. The breaking change here would be anyone that was trying to use Folia while only targeting bukkit ACF.

I tested the commit against Paper 1.19 and Paper 1.20. I did not test against Folia but should be fine...

Clercq commented 1 year ago

@chickeneer it looks like nothing was changed on folia image

Clercq commented 1 year ago

it works perfectly till yesterday

chickeneer commented 1 year ago

I am confused. You are saying it stopped working yesterday? Like before I wrote today's fix?

Has the plugin been recompiled since that today's fix?

Clercq commented 1 year ago

Works perfectly now, thank you!