Hi there guys, so i have made a kit plugin where you can choose kits by clicking on it in an icon menu. But if you havent got the permission to select that kit. It must say: [SurviveIt] Je hebt [KITNAME] niet! It says that, but it says another message to and that is: [SurviveIt] Je hebt switcher niet! So the problem is in the code of switcher [this part of the code]: Code:java @EventHandler public void onInventoryClick(InventoryClickEvent event) { Player player = (Player) event.getWhoClicked(); // The player that clicked the item ItemStack clicked = event.getCurrentItem(); // The item that was clicked Inventory inventory = event.getInventory(); // The inventory that was clicked in if (inventory.getName().equals(inv.getName())) { // The inventory is our custom Inventory if (clicked.getType() == Material.SNOW_BALL) { // The item that the player clicked it if (player.hasPermission("SurviveItKits.Switcher")) { event.setCancelled(true); // Make it so the dirt is back in its original spot player.closeInventory(); // Closes there inventory player.getInventory().setArmorContents(null); player.getInventory().clear(); player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 64)); // Adds player.getInventory().addItem(new ItemStack(Material.STONE_SWORD, 1)); player.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE, 1)); player.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS, 1)); ItemStack SnowBall1 = new ItemStack(Material.SNOW_BALL, 64); ItemMeta SnowBall1Meta = SnowBall1.getItemMeta(); SnowBall1Meta.setLore(Arrays.asList(new String[] { ChatColor.GREEN + "Gebruik: Richt en gooi op een speler." })); SnowBall1Meta.setDisplayName(ChatColor.WHITE + "Switchers"); SnowBall1.setItemMeta(SnowBall1Meta); player.getInventory().addItem(SnowBall1); player.getInventory().addItem(new ItemStack(Material.BOW, 1)); player.getInventory().addItem(new ItemStack(Material.ARROW, 32)); player.teleport(new Location(Bukkit.getWorld("world"),-1955,100,64)); try { ParticleEffects.ENCHANTMENT_TABLE .sendToPlayer(player, player.getLocation(), 1.0F, 1.0F, 1.0F, 1.0F, 60); ParticleEffects.ENCHANTMENT_TABLE .sendToPlayer(player, player.getLocation(), 1.0F, 1.0F, 1.0F, 1.0F, 60); ParticleEffects.ENCHANTMENT_TABLE .sendToPlayer(player, player.getLocation(), 1.0F, 1.0F, 1.0F, 1.0F, 60); ParticleEffects.PORTAL .sendToPlayer(player, player.getLocation(), 1.0F, 1.0F, 1.0F, 1.0F, 60); ParticleEffects.PORTAL .sendToPlayer(player, player.getLocation(), 1.0F, 1.0F, 1.0F, 1.0F, 60); ParticleEffects.PORTAL .sendToPlayer(player, player.getLocation(), 1.0F, 1.0F, 1.0F, 1.0F, 60); } catch (Exception e1) { e1.printStackTrace(); Location loc = player.getLocation(); player.playSound(loc, Sound.PORTAL_TRAVEL, 2.0F, 1.0F); } } } else { if (inventory.getName().equals(inv.getName())) if (clicked.getType() == Material.SNOW_BALL) event.setCancelled(true); player.closeInventory(); player.sendMessage(ChatColor.GOLD + "[" + ChatColor.DARK_RED + "SurviveIt" + ChatColor.GOLD + "] " + ChatColor.RED + "Je hebt switcher niet!"); return; } } } But what is the problem ? I hope you guys can help me, and heres the whole code: http://dev.bukkit.org/paste/tjb3zwspu7m95yxq/
lines 62 and 63 should probably contained within {} along with line 61, not sure of your exact idea on the requirements for it to fire or not so I can't say for sure
holysteward Thanks! But now if i select Switcher i can just take the item out of the icon menu and nothing happens. No message etc.
Weszzz Try this, Code:java @EventHandlerpublic void onInventoryClick(InventoryClickEvent event) { Player player = (Player) event.getWhoClicked(); // The player that clicked the item ItemStack clicked = event.getCurrentItem(); // The item that was clicked Inventory inventory = event.getInventory(); // The inventory that was clicked in if (inventory.getName().equals(inv.getName())) { // The inventory is our custom Inventory if (clicked.getType() == Material.SNOW_BALL) { // The item that the player clicked it if (player.hasPermission("SurviveItKits.Switcher")) { event.setCancelled(true); // Make it so the dirt is back in its original spot player.closeInventory(); // Closes there inventory player.getInventory().setArmorContents(null); player.getInventory().clear(); player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 64)); // Adds player.getInventory().addItem(new ItemStack(Material.STONE_SWORD, 1)); player.getInventory().setChestplate(new ItemStack(Material.IRON_CHESTPLATE, 1)); player.getInventory().setBoots(new ItemStack(Material.IRON_BOOTS, 1)); ItemStack SnowBall1 = new ItemStack(Material.SNOW_BALL, 64); ItemMeta SnowBall1Meta = SnowBall1.getItemMeta(); SnowBall1Meta.setLore(Arrays.asList(new String[] { ChatColor.GREEN + "Gebruik: Richt en gooi op een speler." })); SnowBall1Meta.setDisplayName(ChatColor.WHITE + "Switchers"); SnowBall1.setItemMeta(SnowBall1Meta); player.getInventory().addItem(SnowBall1); player.getInventory().addItem(new ItemStack(Material.BOW, 1)); player.getInventory().addItem(new ItemStack(Material.ARROW, 32)); player.teleport(new Location(Bukkit.getWorld("world"),-1955,100,64)); try { ParticleEffects.ENCHANTMENT_TABLE .sendToPlayer(player, player.getLocation(), 1.0F, 1.0F, 1.0F, 1.0F, 60); ParticleEffects.ENCHANTMENT_TABLE .sendToPlayer(player, player.getLocation(), 1.0F, 1.0F, 1.0F, 1.0F, 60); ParticleEffects.ENCHANTMENT_TABLE .sendToPlayer(player, player.getLocation(), 1.0F, 1.0F, 1.0F, 1.0F, 60); ParticleEffects.PORTAL .sendToPlayer(player, player.getLocation(), 1.0F, 1.0F, 1.0F, 1.0F, 60); ParticleEffects.PORTAL .sendToPlayer(player, player.getLocation(), 1.0F, 1.0F, 1.0F, 1.0F, 60); ParticleEffects.PORTAL .sendToPlayer(player, player.getLocation(), 1.0F, 1.0F, 1.0F, 1.0F, 60); } catch (Exception e1) { e1.printStackTrace(); Location loc = player.getLocation(); player.playSound(loc, Sound.PORTAL_TRAVEL, 2.0F, 1.0F); } } else { event.setCancelled(true); player.closeInventory(); player.sendMessage(ChatColor.GOLD + "[" + ChatColor.DARK_RED + "SurviveIt" + ChatColor.GOLD + "] " + ChatColor.RED + "Je hebt switcher niet!"); return; } } }}