"No API implementation set. Is Holographic Displays enabled?" but HolographicDisplays is loaded and enabled
MattW-source opened this issue ยท 1 comments
Confirmation
- I have read the FAQ.
- I have tested the latest development build of Holographic Displays and the bug is still present.
- I have updated Spigot (and ProtocolLib if installed) to the latest release for my particular Minecraft version.
- I made sure the bug hasn't already been reported on the issue tracker.
Description
We are unable to use HolographicDisplays in an external plugin due to java.lang.IllegalStateException: No API implementation set. Is Holographic Displays enabled?
despite the plugin being loaded and enabled prior to attempting to enable the plugin that uses HolographicDisplays.
I have exhausted my list of troubleshooting steps, such as ensuring everything is up to date. I am unable to determine the cause of the IllegalStateException.
How to reproduce
- Create a plugin that uses HolographicDisplays using the most recent version (2.4.9)
- Have a server that has HolographicDisplays 2.4.9 installed
- Start up the server with both plugins.
java.lang.IllegalStateException
is thrown
Server version
This server is running Paper version git-Paper-790 (MC: 1.16.5) (Implementing API version 1.16.5-R0.1-SNAPSHOT)
Holographic Displays version
HolographicDisplays version 2.4.9
ProtocolLib version (if installed)
ProtocolLib version 4.7.0
Installed plugins that allow players to join with multiple Minecraft versions
ViaVersion-4.0.1, ViaBackwards-4.0.1, ViaRewind-2.0.1
Additional information
Error:
[09:48:33 ERROR]: Error occurred while enabling MomentoIslandCompetition v1.2.1-1.16 (Is it up to date?)
java.lang.IllegalStateException: No API implementation set. Is Holographic Displays enabled?
at com.gmail.filoghost.holographicdisplays.api.internal.BackendAPI.getImplementation(BackendAPI.java:36) ~[?:?]
at com.gmail.filoghost.holographicdisplays.api.HologramsAPI.createHologram(HologramsAPI.java:46) ~[?:?]
at com.dnyferguson.momentoislandcompetition.MomentoIslandCompetition.onEnable(MomentoIslandCompetition.java:88) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Paper-790]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.16.5.jar:git-Paper-790]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.16.5.jar:git-Paper-790]
at com.rylinaux.plugman.util.PluginUtil.load(PluginUtil.java:366) ~[?:?]
at com.rylinaux.plugman.util.PluginUtil.load(PluginUtil.java:318) ~[?:?]
at com.rylinaux.plugman.util.PluginUtil.reload(PluginUtil.java:380) ~[?:?]
at com.rylinaux.plugman.command.ReloadCommand.execute(ReloadCommand.java:122) ~[?:?]
at com.rylinaux.plugman.PlugManCommandHandler.onCommand(PlugManCommandHandler.java:95) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[patched_1.16.5.jar:git-Paper-790]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[patched_1.16.5.jar:git-Paper-790]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.dispatchCommand(CraftServer.java:826) ~[patched_1.16.5.jar:git-Paper-790]
at net.minecraft.server.v1_16_R3.PlayerConnection.handleCommand(PlayerConnection.java:2185) ~[patched_1.16.5.jar:git-Paper-790]
at net.minecraft.server.v1_16_R3.PlayerConnection.c(PlayerConnection.java:2000) ~[patched_1.16.5.jar:git-Paper-790]
at net.minecraft.server.v1_16_R3.PlayerConnection.a(PlayerConnection.java:1953) ~[patched_1.16.5.jar:git-Paper-790]
at net.minecraft.server.v1_16_R3.PacketPlayInChat.a(PacketPlayInChat.java:49) ~[patched_1.16.5.jar:git-Paper-790]
at net.minecraft.server.v1_16_R3.PacketPlayInChat.a(PacketPlayInChat.java:7) ~[patched_1.16.5.jar:git-Paper-790]
at net.minecraft.server.v1_16_R3.PlayerConnectionUtils.lambda$ensureMainThread$1(PlayerConnectionUtils.java:35) ~[patched_1.16.5.jar:git-Paper-790]
at net.minecraft.server.v1_16_R3.TickTask.run(SourceFile:18) ~[patched_1.16.5.jar:git-Paper-790]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeTask(IAsyncTaskHandler.java:136) ~[patched_1.16.5.jar:git-Paper-790]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) ~[patched_1.16.5.jar:git-Paper-790]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.executeNext(IAsyncTaskHandler.java:109) ~[patched_1.16.5.jar:git-Paper-790]
at net.minecraft.server.v1_16_R3.MinecraftServer.bb(MinecraftServer.java:1271) ~[patched_1.16.5.jar:git-Paper-790]
at net.minecraft.server.v1_16_R3.MinecraftServer.executeNext(MinecraftServer.java:1264) ~[patched_1.16.5.jar:git-Paper-790]
at net.minecraft.server.v1_16_R3.IAsyncTaskHandler.awaitTasks(IAsyncTaskHandler.java:119) ~[patched_1.16.5.jar:git-Paper-790]
at net.minecraft.server.v1_16_R3.MinecraftServer.sleepForTick(MinecraftServer.java:1225) ~[patched_1.16.5.jar:git-Paper-790]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1139) ~[patched_1.16.5.jar:git-Paper-790]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-790]
at java.lang.Thread.run(Thread.java:831) [?:?]
Our plugin.yml is as follows
softdepend: [PlaceholderAPI]
depend: [SuperiorSkyblock2, HolographicDisplays]
Our onEnable method contains a check as recommended by the API docs
if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) {
getLogger().severe("*** HolographicDisplays is not installed or not enabled. ***");
getLogger().severe("*** This plugin will be disabled. ***");
this.setEnabled(false);
return;
}
The exception is thrown at this line
hologram = HologramsAPI.createHologram(this, loc);
We are using the following maven configuration for building our plugin
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
</repository>
<dependency>
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
<artifactId>holographicdisplays-api</artifactId>
<version>2.4.9</version>
<scope>provided</scope>
</dependency>
I can see in console that holographic displays is enabled prior to MomentoIslandCompetition
[09:55:25] [Server thread/INFO]: [HolographicDisplays] Loading HolographicDisplays v2.4.9
...
[09:55:26] [Server thread/INFO]: [MomentoIslandCompetition] Loading MomentoIslandCompetition v1.2.1-1.16
...
[09:55:31] [Server thread/INFO]: [HolographicDisplays] Enabling HolographicDisplays v2.4.9
[09:55:31] [Server thread/INFO]: [HolographicDisplays] Enabled player relative placeholders with ProtocolLib.
...
[09:55:42] [Server thread/INFO]: [MomentoIslandCompetition] Enabling MomentoIslandCompetition v1.2.1-1.16
[09:55:42] [Server thread/INFO]: [MomentoIslandCompetition] *** HolographicsDisplays IS INSTALLED AND ENABLED ***
[09:55:42] [Server thread/INFO]: [MomentoIslandCompetition] Loaded item: IRON_BLOCK => 1.0 levels.
[09:55:42] [Server thread/INFO]: [MomentoIslandCompetition] Loaded item: GOLD_BLOCK => 5.0 levels.
[09:55:42] [Server thread/INFO]: [MomentoIslandCompetition] Loaded item: DIAMOND_BLOCK => 20.0 levels.
[09:55:42] [Server thread/INFO]: [MomentoIslandCompetition] Loaded item: EMERALD_BLOCK => 80.0 levels.
[09:55:42] [Server thread/INFO]: [MomentoIslandCompetition] Loaded 4 items.
[09:55:42] [Server thread/ERROR]: Error occurred while enabling MomentoIslandCompetition v1.2.1-1.16 (Is it up to date?)
Got to the bottom of this after trying to run the plugin with the holographic stuff disabled, only to hit a similar issue with the next dependency that gets called in the onEnable method.
For those interested or googling this in the future. This particular problem was caused by Maven building the plugin in a weird way causing some of the dependency jars to not be built in correctly.
[WARNING] maven-shade-plugin has detected that some class files are
[WARNING] present in two or more JARs. When this happens, only one
[WARNING] single version of the class is copied to the uber jar.
[WARNING] Usually this is not harmful and you can skip these warnings,
[WARNING] otherwise try to manually exclude artifacts based on
[WARNING] mvn dependency:tree -Ddetail=true and the above output.
[WARNING] See http://maven.apache.org/plugins/maven-shade-plugin/
[INFO] Replacing original artifact with shaded artifact.
Maven should spit out another version prefixed with original-
. Using that version resolved the problem for us.
Other common causes of the IllegalStateException is Holographic Displays not being loaded before your plugin (make sure to specify it in Depend or Softdepend in the plugin.yml).