Closed Abelkrijgtalles closed 5 months ago
You need to put the code which uses the CommandAPI into a separate class and use such class only after having loaded the dependencies. This way Java doesn't try to load classes from the CommandAPI before it gets loaded by Libby.
For example:
// Plugin main class
public void loadLibs() {
// load dependencies
}
@Override
public void onLoad() {
loadLibs();
new CommandAPIManager(this).load();
}
// CommandAPIManager.java
public class CommandAPIManager {
private final JavaPlugin plugin;
public CommandAPIManager(JavaPlugin plugin) {
this.plugin = plugin;
}
public void load() {
CommandAPI.onLoad(new CommandAPIBukkitConfig(plugin));
}
}
Thank you
It still doesn't work, @frengor.
Try moving also these lines into CommandUtil
.
I did fix it, but not on this way. I used the built-in dependency system from spigot. See https://www.spigotmc.org/threads/when-using-libby-in-onload-a-java-lang-noclassdeffounderror-is-called.634222 for the spigot post where I fixed it.
When (down)loading the library and calling it in onLoad(), java/minecraft throws this nasty error:
The code that loads the library is this:
When disabling the
CommandAPI.onLoad(new CommandAPIBukkitConfig(this));
, you can see that libby proceeds with (down)loading the libs and just executing normal behaviour.I seriously don't have any idea how to fix this, other than just letting Mojang Maps (my plugin) manually download the CommandAPI plugin and use
commandapi-bukkit-core
instead ofcommandapi-bukkit-shade
.Full code Full log