bergerhealer / BKCommonLib

An extensive library used in bergerhealer's plugins
Other
181 stars 45 forks source link

BKCommonLib is not enabled - Plugin Instance can not be obtained! (disjointed Class state?) #171

Closed beAPanda closed 4 months ago

beAPanda commented 4 months ago
BkCommonLib version: 1.20.4-v1
Spigot version: 1.20.4

Problem or bug:

I get the following error: BKCommonLib is not enabled - Plugin Instance can not be obtained! (disjointed Class state?)

Expected behaviour:

Steps to reproduce:

I have created a plugin. Then I added the following code to pom.xml:

      <repository>
          <id>MG-Dev Jenkins CI Maven Repository</id>
          <url>https://ci.mg-dev.eu/plugin/repository/everything</url>
      </repository>

      <dependency>
          <groupId>com.bergerkiller.bukkit</groupId>
          <artifactId>BKCommonLib</artifactId>
          <version>1.20.4-v1</version>
          <scope>compile</scope>
      </dependency>

I have added the following to the plugin.yml:

depend:
  - BKCommonLib

Then I added the plugin “BKCommonLib-1.20.6-v1-1749.jar” to the plugin folder. (I don't know if this is necessary) When I start the server now, BKCommonLib loads successfully. [BKCommonLib] Loading BKCommonLib v1.20.6-v1

[15:22:17] [Server thread/INFO]: [BKCommonLib] Enabling BKCommonLib v1.20.6-v1
[15:22:17] [Server thread/INFO]: [BKCommonLib] BKCommonLib is running on Spigot (4090-Spigot-b754dcc-38b1f49) : v1_20_R3 (Minecraft 1.20.4)
[15:22:18] [Server thread/INFO]: [BKCommonLib] Less complicated than the American election.
[15:22:18] [Server thread/INFO]: [BKCommonLib] BKCommonLib version 1.20.6-v1 (build: 1749) enabled! (0.584s)

But if the following code is called, the error occurs

            CommonEntity<?> entity = CommonEntity.get(e);
            entity.setController(new EntityController<CommonEntity<?>>() {
                public boolean onEntityCollision(Entity entity) {
                    return false; // True to allow, False to deny
                }

                public boolean onBlockCollision(Block block, BlockFace hitFace) {
                    return false; //True to allow, False to deny
                }
            });
An error occurred during server bootstrapping:
java.lang.RuntimeException: BKCommonLib is not enabled - Plugin Instance can not be obtained! (disjointed Class state?)
        at com.bergerkiller.bukkit.common.internal.CommonPlugin.getInstance(CommonPlugin.java:153) ~[?:?]
        at com.bergerkiller.bukkit.common.internal.cdn.MojangIO.getCacheFolder(MojangIO.java:41) ~[?:?]
        at com.bergerkiller.bukkit.common.internal.cdn.MojangMappings.fromCacheOrDownload(MojangMappings.java:201) ~[?:?]
        at com.bergerkiller.bukkit.common.internal.cdn.MojangSpigotRemapper.load(MojangSpigotRemapper.java:256) ~[?:?]
        at com.bergerkiller.bukkit.common.server.CraftBukkitServer.postInit(CraftBukkitServer.java:129) ~[?:?]
        at com.bergerkiller.bukkit.common.internal.CommonBootstrap.initCommonServer(CommonBootstrap.java:242) ~[?:?]
        at com.bergerkiller.bukkit.common.Common.<clinit>(Common.java:137) ~[?:?]
        at com.bergerkiller.generated.org.bukkit.craftbukkit.entity.CraftEntityHandle.<clinit>(CraftEntityHandle.java:16) ~[?:?]
        at com.bergerkiller.bukkit.common.conversion.type.HandleConversion.toEntityHandle(HandleConversion.java:102) ~[?:?]
        at com.bergerkiller.bukkit.common.entity.CommonEntity.get(CommonEntity.java:839) ~[?:?]
        at de.pandadevelopments.unrailed.other.MapBuilder.createNewWorld(MapBuilder.java:87) ~[?:?]
        at de.pandadevelopments.unrailed.other.Game.start(Game.java:34) ~[?:?]
        at de.pandadevelopments.unrailed.event.ButtonListener.onPlayerToggleSneak(ButtonListener.java:41) ~[?:?]
        at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:580) ~[?:?]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[spigot-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:600) ~[spigot-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:587) ~[spigot-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:2147) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4090-Spigot-b754dcc-38b1f49]
        at net.minecraft.network.protocol.game.PacketPlayInEntityAction.a(SourceFile:37) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4090-Spigot-b754dcc-38b1f49]
        at net.minecraft.network.protocol.game.PacketPlayInEntityAction.a(SourceFile:7) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4090-Spigot-b754dcc-38b1f49]
        at net.minecraft.network.protocol.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:33) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4090-Spigot-b754dcc-38b1f49]
        at net.minecraft.server.TickTask.run(SourceFile:18) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4090-Spigot-b754dcc-38b1f49]
        at net.minecraft.util.thread.IAsyncTaskHandler.d(SourceFile:156) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4090-Spigot-b754dcc-38b1f49]
        at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.d(SourceFile:23) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4090-Spigot-b754dcc-38b1f49]
        at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1191) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4090-Spigot-b754dcc-38b1f49]
        at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:1) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4090-Spigot-b754dcc-38b1f49]
        at net.minecraft.util.thread.IAsyncTaskHandler.x(SourceFile:130) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4090-Spigot-b754dcc-38b1f49]
        at net.minecraft.server.MinecraftServer.bl(MinecraftServer.java:1170) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4090-Spigot-b754dcc-38b1f49]
        at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1163) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4090-Spigot-b754dcc-38b1f49]
        at net.minecraft.util.thread.IAsyncTaskHandler.c(SourceFile:139) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4090-Spigot-b754dcc-38b1f49]
        at net.minecraft.server.MinecraftServer.w_(MinecraftServer.java:1147) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4090-Spigot-b754dcc-38b1f49]
        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1060) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4090-Spigot-b754dcc-38b1f49]
        at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.20.4-R0.1-SNAPSHOT.jar:4090-Spigot-b754dcc-38b1f49]
        at java.lang.Thread.run(Thread.java:1583) ~[?:?]
bergerkiller commented 4 months ago

Perhaps you need to use <scope>provided</scope> instead of <scope>compile</scope>? Its possible bkcl classes are getting shaded into your plugin. Check file size.