MinusKube / SmartInvs

Advanced Inventory API for your Minecraft Bukkit plugins.
https://minuskube.gitbook.io/smartinvs/
Apache License 2.0
263 stars 65 forks source link

how to use this? #191

Open creamgod45 opened 3 years ago

creamgod45 commented 3 years ago

Put it inside your plugin jar, initialize an InventoryManager in your plugin (don't forget to call the init() method), and add a .manager(invManager) to your SmartInventory Builders. what do you mean ?

java.lang.NoClassDefFoundError: Could not initialize class cg.creamgod45.SimpleInventory
        at cg.creamgod45.CG_ignoregui.onEnable(CG_ignoregui.java:26) ~[CG_ignoregui.jar:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[patched_1.17.1.jar:git-Purpur-1372]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.17.1.jar:git-Purpur-1372]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.17.1.jar:git-Purpur-1372]
        at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:535) ~[patched_1.17.1.jar:git-Purpur-1372]
        at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:449) ~[patched_1.17.1.jar:git-Purpur-1372]
        at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:288) ~[patched_1.17.1.jar:git-Purpur-1372]
        at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1216) ~[patched_1.17.1.jar:git-Purpur-1372]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:321) ~[patched_1.17.1.jar:git-Purpur-1372]
        at java.lang.Thread.run(Thread.java:831) [?:?]
creamgod45 commented 3 years ago

Caused by: java.lang.IllegalStateException: The manager of the SmartInventory.Builder must be set, or the SmartInvs should be loaded as a plugin. at fr.minuskube.inv.SmartInventory$Builder.build(SmartInventory.java:163) ~[CG_ignoregui.jar:?] at cg.creamgod45.SimpleInventory.(SimpleInventory.java:20) ~[CG_ignoregui.jar:?] at cg.creamgod45.cmdgui.onCommand(cmdgui.java:15) ~[CG_ignoregui.jar:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[patched_1.17.1.jar:git-Purpur-1372] ... 21 more

MinusKube commented 3 years ago

Do something like this inside your main class:

private InventoryManager invManager;

@Override
public void onEnable() {
    this.invManager = new InventoryManager(this);
    this.invManager.init();
}

Then, when creating your inventory:

SmartInventory.builder()
    .size(...)
    .manager(invManager)
    ...