Shopkeepers

Shopkeepers

2M Downloads

Error "Citizens API implementation not set"

games4681 opened this issue ยท 2 comments

commented

[ERROR] [Shopkeepers] Shopkeeper 24: Error during ticking stop!
23.08 05:43:49 [Server] [INFO] java.lang.IllegalStateException: no implementation set
23.08 05:43:49 [Server] [INFO] at net.citizensnpcs.api.CitizensAPI.getImplementation(CitizensAPI.java:92) ~[Citizens-2.0.32-b3188.jar:?]
23.08 05:43:49 [Server] [INFO] at net.citizensnpcs.api.CitizensAPI.getNPCRegistry(CitizensAPI.java:132) ~[Citizens-2.0.32-b3188.jar:?]
23.08 05:43:49 [Server] [INFO] at com.nisovin.shopkeepers.shopobjects.citizens.SKCitizensShopObject.getNPC(SKCitizensShopObject.java:195) ~[Shopkeepers-2.17.1.jar:?]
23.08 05:43:49 [Server] [INFO] at com.nisovin.shopkeepers.shopobjects.citizens.SKCitizensShopObject.updateShopkeeperLocation(SKCitizensShopObject.java:751) ~[Shopkeepers-2.17.1.jar:?]
23.08 05:43:49 [Server] [INFO] at com.nisovin.shopkeepers.shopobjects.citizens.SKCitizensShopObject.onStopTicking(SKCitizensShopObject.java:649) ~[Shopkeepers-2.17.1.jar:?]
23.08 05:43:49 [Server] [INFO] at com.nisovin.shopkeepers.shopkeeper.AbstractShopkeeper.onStopTicking(AbstractShopkeeper.java:1511) ~[Shopkeepers-2.17.1.jar:?]
23.08 05:43:49 [Server] [INFO] at com.nisovin.shopkeepers.shopkeeper.AbstractShopkeeper.informStopTicking(AbstractShopkeeper.java:1504) ~[Shopkeepers-2.17.1.jar:?]
23.08 05:43:49 [Server] [INFO] at com.nisovin.shopkeepers.shopkeeper.ticking.ShopkeeperTicker.stopTicking(ShopkeeperTicker.java:199) ~[Shopkeepers-2.17.1.jar:?]
23.08 05:43:49 [Server] [INFO] at com.nisovin.shopkeepers.shopkeeper.activation.ShopkeeperChunkActivator.deactivateChunk(ShopkeeperChunkActivator.java:567) ~[Shopkeepers-2.17.1.jar:?]
23.08 05:43:49 [Server] [INFO] at com.nisovin.shopkeepers.shopkeeper.activation.ShopkeeperChunkActivator.deactivateChunkIfShouldBeInactive(ShopkeeperChunkActivator.java:689) ~[Shopkeepers-2.17.1.jar:?]
23.08 05:43:49 [Server] [INFO] at java.util.ArrayList.forEach(ArrayList.java:1511) ~[?:?]
23.08 05:43:49 [Server] [INFO] at com.nisovin.shopkeepers.shopkeeper.activation.ShopkeeperChunkActivator.deactivateChunks(ShopkeeperChunkActivator.java:680) ~[Shopkeepers-2.17.1.jar:?]
23.08 05:43:49 [Server] [INFO] at java.util.ArrayList.forEach(ArrayList.java:1511) ~[?:?]
23.08 05:43:49 [Server] [INFO] at com.nisovin.shopkeepers.shopkeeper.activation.ShopkeeperChunkActivator.deactivateShopkeepersInAllWorlds(ShopkeeperChunkActivator.java:649) ~[Shopkeepers-2.17.1.jar:?]
23.08 05:43:49 [Server] [INFO] at com.nisovin.shopkeepers.SKShopkeepersPlugin.onDisable(SKShopkeepersPlugin.java:456) ~[Shopkeepers-2.17.1.jar:?]
23.08 05:43:49 [Server] [INFO] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:283) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
23.08 05:43:49 [Server] [INFO] at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.disablePlugin(PaperPluginInstanceManager.java:224) ~[paper-1.20.1.jar:git-Paper-158]
23.08 05:43:49 [Server] [INFO] at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.disablePlugin(PaperPluginManagerImpl.java:109) ~[paper-1.20.1.jar:git-Paper-158]
23.08 05:43:49 [Server] [INFO] at org.bukkit.plugin.SimplePluginManager.disablePlugin(SimplePluginManager.java:537) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
23.08 05:43:49 [Server] [INFO] at com.rylinaux.plugman.util.PaperPluginUtil.unload(PaperPluginUtil.java:567) ~[PlugManX.jar:?]
23.08 05:43:49 [Server] [INFO] at com.rylinaux.plugman.util.PaperPluginUtil.reload(PaperPluginUtil.java:525) ~[PlugManX.jar:?]
23.08 05:43:49 [Server] [INFO] at com.rylinaux.plugman.command.ReloadCommand.execute(ReloadCommand.java:125) ~[PlugManX.jar:?]
23.08 05:43:49 [Server] [INFO] at com.rylinaux.plugman.PlugManCommandHandler.onCommand(PlugManCommandHandler.java:97) ~[PlugManX.jar:?]
23.08 05:43:49 [Server] [INFO] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
23.08 05:43:49 [Server] [INFO] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155) ~[paper-api-1.20.1-R0.1-SNAPSHOT.jar:?]
23.08 05:43:49 [Server] [INFO] at org.bukkit.craftbukkit.v1_20_R1.CraftServer.dispatchCommand(CraftServer.java:1007) ~[paper-1.20.1.jar:git-Paper-158]
23.08 05:43:49 [Server] [INFO] at org.bukkit.craftbukkit.v1_20_R1.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:64) ~[paper-1.20.1.jar:git-Paper-158]
23.08 05:43:49 [Server] [INFO] at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:265) ~[paper-1.20.1.jar:?]
23.08 05:43:49 [Server] [INFO] at net.minecraft.commands.Commands.performCommand(Commands.java:324) ~[?:?]
23.08 05:43:49 [Server] [INFO] at net.minecraft.commands.Commands.performCommand(Commands.java:308) ~[?:?]
23.08 05:43:49 [Server] [INFO] at net.minecraft.server.network.ServerGamePacketListenerImpl.performChatCommand(ServerGamePacketListenerImpl.java:2354) ~[?:?]
23.08 05:43:49 [Server] [INFO] at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$21(ServerGamePacketListenerImpl.java:2314) ~[?:?]
23.08 05:43:49 [Server] [INFO] at net.minecraft.util.thread.BlockableEventLoop.lambda$submitAsync$0(BlockableEventLoop.java:59) ~[?:?]
23.08 05:43:49 [Server] [INFO] at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
23.08 05:43:49 [Server] [INFO] at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.20.1.jar:git-Paper-158]
23.08 05:43:49 [Server] [INFO] at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]
23.08 05:43:49 [Server] [INFO] at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
23.08 05:43:49 [Server] [INFO] at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1339) ~[paper-1.20.1.jar:git-Paper-158]
23.08 05:43:49 [Server] [INFO] at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:197) ~[paper-1.20.1.jar:git-Paper-158]
23.08 05:43:49 [Server] [INFO] at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
23.08 05:43:49 [Server] [INFO] at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1316) ~[paper-1.20.1.jar:git-Paper-158]
23.08 05:43:49 [Server] [INFO] at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1309) ~[paper-1.20.1.jar:git-Paper-158]
23.08 05:43:49 [Server] [INFO] at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
23.08 05:43:49 [Server] [INFO] at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1287) ~[paper-1.20.1.jar:git-Paper-158]
23.08 05:43:49 [Server] [INFO] at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1175) ~[paper-1.20.1.jar:git-Paper-158]
23.08 05:43:49 [Server] [INFO] at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318) ~[paper-1.20.1.jar:git-Paper-158]
23.08 05:43:49 [Server] [INFO] at java.lang.Thread.run(Thread.java:833) ~[?:?]
23.08 05:43:49 [Server] [ERROR] [Shopkeepers] Shopkeeper 25: Error during ticking stop!
23.08 05:43:49 [Server] [INFO] java.lang.IllegalStateException: no implementation set
23.08 05:43:49 [Server] [INFO] at net.citizensnpcs.api.CitizensAPI.getImplementation(CitizensAPI.java:92) ~[Citizens-2.0.32-b3188.jar:?]
23.08 05:43:49 [Server] [INFO] at net.citizensnpcs.api.CitizensAPI.getNPCRegistry(CitizensAPI.java:132) ~[Citizens-2.0.32-b3188.jar:?]
23.08 05:43:49 [Server] [INFO] at com.nisovin.shopkeepers.shopobjects.citizens.SKCitizensShopObject.getNPC(SKCitizensShopObject.java:195) ~[Shopkeepers-2.17.1.jar:?]
23.08 05:43:49 [Server] [INFO] at com.nisovin.shopkeepers.shopobjects.citizens.SKCitizensShopObject.updateShopkeeperLocation(SKCitizensShopObject.java:751) ~[Shopkeepers-2.17.1.jar:?]
23.08 05:43:49 [Server] [INFO] at com.nisovin.shopkeepers.shopobjects.citizens.SKCitizensShopObject.onStopTicking(SKCitizensShopObject.java:649) ~[Shopkeepers-2.17.1.jar:?]
23.08 05:43:49 [Server] [INFO] at com.nisovin.shopkeepers.shopkeeper.AbstractShopkeeper.onStopTicking(AbstractShopkeeper.java:1511) ~[Shopkeepers-2.17.1.jar:?]
23.08 05:43:49 [Server] [INFO] at com.nisovin.shopkeepers.shopkeeper.AbstractShopkeeper.informStopTicking(AbstractShopkeeper.java:1504) ~[Shopkeepers-2.17.1.jar:?]
23.08 05:43:49 [Server] [INFO] at com.nisovin.shopkeepers.shopkeeper.ticking.ShopkeeperTicker.stopTicking(ShopkeeperTicker.java:199) ~[Shopkeepers-2.17.1.jar:?]
23.08 05:43:55 [PebbleHost] Skipped 740 lines due to rate limit (500/s)

commented

The errors seem to indicate that the Citizens plugin was not correctly enabled / initialized. However, ideally the Shopkeepers plugin should handle this situation better in this case, so I will have to check that.

commented

The shopkeepers plugin already reacts to the plugin disable event of the Citizens plugin, and the Citizens plugin disables itself automatically whenever its implementation is cleared, or if it fails to properly enable. So I am not sure currently how to reproduce this.

However, I think there were past versions (CitizensDev/Citizens2@9904e03) in which Citizens would run its cleanup logic (including unsetting the API implementation) whenever a plugin that depends on Citizens is disabled. This could explain the stack trace of the Citizens API implementation suddenly no longer being available without notice during the disabling of the Shopkeepers plugin. But the stack trace seems to indicate that Citizens v2.0.32 is being used, which should already contain the linked change in behavior.

I tried to reproduce this with plugman: Disabling Citizens, and then reloading Shopkeepers did not have the effect.
However, trying to enable Citizens again failed with an exception and I get exceptions during the initial DelayedSetupTask and during ticking of the shopkeepers. However, I get NRE instead of the "no implementation set" error, indicating that an API implementation is set but not properly enabled internally due to the error during plugin enable.

Also, reloading the Citizens plugin via plugman appears to "work", but internally leaves the Citizens API in an not initialized state. My current guess is that this might caused by the reloaded Citizens plugin loading its classes in a new separate class loader whereas other plugins such as Shopkeepers still reference the original classes. If that is the case, I don't think there is a way to make this work. You will have to avoid reloading individual plugins via PlugMan. I have added an entry about this issue to the "Known Issues" page inside the wiki.

In either case, the next versions of the Shopkeepers plugin will now perform additional checks to verify that the Citziens plugin is properly enabled before we try to use the Citizens API.