Hey, I have a problem by defining a variable. I need to define p what I tried to do. Is it the right way: "Player p = (Player) e.getWhoClicked();" But when I do this it says: "cannot convert from void to Inventory" Here the part of the code: Code (Text): @EventHandler public void onClick1(InventoryClickEvent e) { Player p = (Player) e.getWhoClicked(); Inventory shop = openShop(p); // it says: "Type mismatch: cannot convert from void to Inventory" Inventory Eff =Bukkit.createInventory(e.getWhoClicked(), 9*1, "§eEffekte"); fillInventory(Eff, Utils_Item.createItem(Material.STAINED_GLASS_PANE, 1, 7, "")); Eff.setItem(2, Utils_Item.createItem(Material.LAVA_BUCKET, 1, 0, "§cLava")); Eff.setItem(4, Utils_Item.createItem(Material.RED_ROSE, 1, 0, "§4Herzen")); Eff.setItem(6, Utils_Item.createItem(Material.GLOWSTONE_DUST, 1, 0, "§fKon§afetti")); Eff.setItem(8, Utils_Item.createItem(Material.BARRIER, 1, 0, "§cZurück")); Eff.setItem(0, Utils_Item.createItem(Material.BARRIER, 1, 0, "§cZurück")); if(e.getCurrentItem().getType() == (Material.BLAZE_POWDER)) { e.getWhoClicked().openInventory(Eff); if(e.getCurrentItem().getType() == (Material.BARRIER)) { e.getWhoClicked().openInventory(shop); } } }
Code (Text): public static void openShop(Player p) { Inventory shop = Bukkit.createInventory(null, 9*3, "§2Extras"); fillInventory(shop, Utils_Item.createItem(Material.STAINED_GLASS_PANE, 1, 7, "")); shop.setItem(10, Utils_Item.createItem(Material.SLIME_BLOCK, 1, 0, "§3Ballons")); shop.setItem(12, Utils_Item.createItem(Material.BLAZE_POWDER, 1, 0, "§eEffekte")); shop.setItem(14, Utils_Item.createItem(Material.FISHING_ROD, 1, 0, "§aGadgets")); shop.setItem(16, Utils_Item.createItem(Material.NAME_TAG, 1, 0, "§bPets")); p.openInventory(shop); p.playSound(p.getLocation(), Sound.BLOCK_CHEST_OPEN, 1, 2); } ----- It is in the same file
Try this openShop method: Code (Java): public static Inventory openShop(Player p) { Inventory shop = Bukkit.createInventory(null, 9*3, "§2Extras"); fillInventory(shop, Utils_Item.createItem(Material.STAINED_GLASS_PANE, 1, 7, "")); shop.setItem(10, Utils_Item.createItem(Material.SLIME_BLOCK, 1, 0, "§3Ballons")); shop.setItem(12, Utils_Item.createItem(Material.BLAZE_POWDER, 1, 0, "§eEffekte")); shop.setItem(14, Utils_Item.createItem(Material.FISHING_ROD, 1, 0, "§aGadgets")); shop.setItem(16, Utils_Item.createItem(Material.NAME_TAG, 1, 0, "§bPets")); p.openInventory(shop); p.playSound(p.getLocation(), Sound.BLOCK_CHEST_OPEN, 1, 2); return shop; }