Shynixn / MCCoroutine

MCCoroutine is a library, which adds extensive support for Kotlin Coroutines for Minecraft Server environments.
Other
211 stars 19 forks source link

com.github.shynixn.mccoroutine.bukkit.impl.MCCoroutineImpl not included in shaded jar #106

Closed sanderderks closed 11 months ago

sanderderks commented 1 year ago

Hello, I'm experiencing the following error: Caused by: java.lang.ClassNotFoundException: com.github.shynixn.mccoroutine.bukkit.impl.MCCoroutineImpl

I can't also can't find this class in the shaded jar. Even though other classes of this library are available.

Maven pom.xml: `

net.citizensnpcs
        <artifactId>citizens-main</artifactId>
        <version>2.0.31-SNAPSHOT</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.github.shynixn.mccoroutine</groupId>
        <artifactId>mccoroutine-bukkit-core</artifactId>
        <version>2.13.0</version>
    </dependency>`

Maven shade output: [INFO] Including com.github.shynixn.mccoroutine:mccoroutine-bukkit-api:jar:2.13.0 in the shaded jar. [INFO] Including com.github.shynixn.mccoroutine:mccoroutine-bukkit-core:jar:2.13.0 in the shaded jar.

Am I doing something wrong?

Shynixn commented 1 year ago

Hello,

the best way to check if your .jar file contains a class is to rename it to .zip, open it and check if the MCCoroutineImpl file is actually in there. If not, you have shading problem.

If you intend to only run your plugin on servers from minecraft 1.17 - latest, you can define the shading in the plugin.yml instead of doing it manually. An example can be found here, with my PetBlocks plugin.

sanderderks commented 1 year ago

Thanks for your response and the example you provided. When revealing the contents of my .jar, I found out that the class indeed did not exist. But there is another file in the 'impl' folder.

output of 'ls -R': `./com/github: shynixn/

./com/github/shynixn: mccoroutine/

./com/github/shynixn/mccoroutine: bukkit/

./com/github/shynixn/mccoroutine/bukkit: CoroutineSession.class 'MCCoroutine$Companion.class' MCCoroutineConfiguration.class MCCoroutineKt.class SuspendingCommandExecutor.class impl/ EventExecutionType.class MCCoroutine.class 'MCCoroutineKt$mcCoroutine$2.class' ShutdownStrategy.class SuspendingTabCompleter.class

./com/github/shynixn/mccoroutine/bukkit/impl: 'CoroutineSessionImpl$init$lambda-1$$inlined$Runnable$1.class' `

I agree that this seems to look like a shading issue. Unfortunately I am not using Spigot 1.17 api version, so using the libraries section is not an option.

Shynixn commented 1 year ago

Hm.. seems to be a shading issue on your end. You can try a different mccoroutine version or take a look how different people configure mccoroutine with the maven shade plugin.

Just some random examples from a github search: https://github.com/Nevakanezah/HorseEnhancer/blob/5d105b622f5029e5b1014270f2d42ff9ddcc830b/pom.xml#L234 https://github.com/justADeni/StandAPI/blob/master/pom.xml

sanderderks commented 11 months ago

Hello @Shynixn after I while I found myself a solution to this issue. I'm still not sure what actually caused it (your package or Maven shade)

https://stackoverflow.com/a/77609324/12457587

Thanks for replying on my question!