I tried adding a path for where the user could input the number of rows in the config file and I had to parse the integer since it's a string and it keeps returning an error. I think it may be an error with the instance reference.
public class GUI {
private static Main plugin;
public GUI(Main plugin) {
this.plugin = plugin;
}
public static Inventory inventory;
public static String inventory_name;
public static int inventory_rows = Integer.parseInt(plugin.getConfig().getString("numberOfRows")) * 9;
public static void initialize() {
inventory_name = Utils.chat("&lTest GUI");
inventory = Bukkit.createInventory(null, inventory_rows);
}
public static Inventory GUI (Player player) {
Inventory toReturn = Bukkit.createInventory(null, inventory_rows, inventory_name);
Utils.createItem(inventory, "cobblestone", 1, 1, "&6&lDisplay Name", "&7First lore line", "&7Second lore line.");
toReturn.setContents(inventory.getContents());
return toReturn;
}
public static void clicked(Player player, int slot, ItemStack clicked, Inventory inventory) {
if (clicked.getItemMeta().getDisplayName().equalsIgnoreCase(Utils.chat("&6&lDisplay Name"))) {
player.sendMessage(Utils.chat("&7You have clicked &6&lDisplay Name."));
}
}
}
Here is the console log.
[23:38:49] [Server thread/ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'gui' in plugin TestPlugin v1.1.1
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.dispatchCommand(CraftServer.java:821) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3403-Spigot-f4ff00f-2e61a5f]
at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1939) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3403-Spigot-f4ff00f-2e61a5f]
at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1778) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3403-Spigot-f4ff00f-2e61a5f]
at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1759) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3403-Spigot-f4ff00f-2e61a5f]
at net.minecraft.network.protocol.game.PacketPlayInChat.a(PacketPlayInChat.java:46) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3403-Spigot-f4ff00f-2e61a5f]
at net.minecraft.network.protocol.game.PacketPlayInChat.a(PacketPlayInChat.java:1) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3403-Spigot-f4ff00f-2e61a5f]
at net.minecraft.network.protocol.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:30) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3403-Spigot-f4ff00f-2e61a5f]
at net.minecraft.server.TickTask.run(SourceFile:18) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3403-Spigot-f4ff00f-2e61a5f]
at net.minecraft.util.thread.IAsyncTaskHandler.c(SourceFile:151) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3403-Spigot-f4ff00f-2e61a5f]
at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.c(SourceFile:23) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3403-Spigot-f4ff00f-2e61a5f]
at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1158) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3403-Spigot-f4ff00f-2e61a5f]
at net.minecraft.server.MinecraftServer.c(MinecraftServer.java:1) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3403-Spigot-f4ff00f-2e61a5f]
at net.minecraft.util.thread.IAsyncTaskHandler.y(SourceFile:125) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3403-Spigot-f4ff00f-2e61a5f]
at net.minecraft.server.MinecraftServer.bf(MinecraftServer.java:1137) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3403-Spigot-f4ff00f-2e61a5f]
at net.minecraft.server.MinecraftServer.y(MinecraftServer.java:1130) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3403-Spigot-f4ff00f-2e61a5f]
at net.minecraft.util.thread.IAsyncTaskHandler.bp(SourceFile:110) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3403-Spigot-f4ff00f-2e61a5f]
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1113) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3403-Spigot-f4ff00f-2e61a5f]
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1038) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3403-Spigot-f4ff00f-2e61a5f]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3403-Spigot-f4ff00f-2e61a5f]
at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.NoClassDefFoundError: Could not initialize class io.github.efrank801.gui.GUI
at io.github.efrank801.commands.GUICommand.onCommand(GUICommand.java:30) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
... 21 more