Hi I am making a GUI in inventory but I got problem, I want 6x9 inventory to generate after click on the lost on the first gui, but It gives me this error. My code: Code:java if (ce.getSlot() == 3) { pl.closeInventory(); Inventory x105 = Bukkit.createInventory(null, 54, "MyINV"); int i; for (i = 0; i <= 54; i++) { ItemStack slot99 = new ItemStack(Material.WATER, 1); ItemMeta meta99 = slot99.getItemMeta(); meta99.setDisplayName(ChatColor.AQUA + "Water Field"); slot99.setItemMeta(meta99); x105.setItem(i, slot99); // the error is on this line } pl.openInventory(x105); } Error is exactly there: x105.setItem(i, slot99); // the error is on this line It seems like it does not accept the variable i, but I dont know why. Can someone help me please ?
mostly, its usefull to give us the error message. that way we don't need to look through you code to see whats the wrong part. When typing this, I noticed you used: Code: for (i = 0; i <= 54; i++) { this will loop over an array of the size of 55 (not 54 because pf <=), causing an ArrayOutOfBoundsException to thrown at the last loop. The solution if to change the line: Code: for (i = 0; i <= 54; i++) { into the following Code: for (i = 0; i < 54; i++) { EDIT: didn't looked at the title, it was the same error as I think it was....