Hello! I'm trying to make an interactive inventory, where you can buy things etc. In this inventory, there is a first page, in this page there are different categories. When you press a category, for example "wardrobe", it opens an inventory called wardrobe and closes the previous one, in this inventory, there is a piece of paper called "Back". What it does is that when you click it, it returns you back to the category page. Only problem is, that when you click it, and you get returned to the category page, you can't click anything else. When you click wardrobe again, it doesn't open the wardrobe inventory. I'm really lost here!
Ofcourse My event: Code:java @EventHandlerpublic void inventoryClick(InventoryClickEvent e) {Player p = (Player) e.getWhoClicked();//Shopif(e.getInventory().getName().equals("Cove Shop")) {e.setCancelled(true); if(e.getCurrentItem().getType().equals(Material.LEATHER_CHESTPLATE)) {p.closeInventory();p.openInventory(wardrobeInventory); What this does is checks if I'm pressing the leather chestplate(wardrobe inventory) and opens up the wardrobe. Then, another if in the event: Code:java }//Wardrobeif(e.getInventory().getName().equals(ChatColor.YELLOW + "Choose what to customize!")){if(e.getCurrentItem().getType().equals(Material.LEATHER_HELMET)) { } else if(e.getCurrentItem().getType().equals(Material.LEATHER_CHESTPLATE)) { } else if(e.getCurrentItem().getType().equals(Material.LEATHER_LEGGINGS)) { } else if(e.getCurrentItem().getType().equals(Material.LEATHER_BOOTS)) { } else if(e.getCurrentItem().getType().equals(Material.PAPER)) {p.closeInventory();p.openInventory(shopInventory); }}} Now, when I press the paper, it opens up the shop inventory. But if I press the leather chestplate again, it doesnt open up the wardrobe again. Let me know if you need more code! Bump! Really need help with this, since it's quite advanced to be honest. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
No errors Here is how I initialized the variables Code:java public static Inventory wardrobeInventory;public static Inventory shopInventory; And then, in my generateInventory() method Code:java shopInventory = Bukkit.createInventory(null, 27, "Cove Shop");wardrobeInventory = Bukkit.createInventory(null, 27, ChatColor.GOLD + "Choose what to customize!");
You need to create an inventory holder. instead of using the variable as null, you need to put your holder variable there, thats how I did it before.