Code: @EventHandler public static void OnPlayerDrop(PlayerDropItemEvent Event) { Player player = Event.getPlayer(); int item = player.getItemInHand().getTypeId(); if ((item == 54) && (player.getGameMode() == GameMode.SURVIVAL)) { Event.setCancelled(true); player.sendMessage(ChatColor.BLUE + "[CreaivePolice]" + ChatColor.BLACK + " - " + ChatColor.WHITE + "Dropping This Item is Denied"); Event.setCancelled(true); } } Why is this not working ? Suspose to detect player in survival and if the player is holding item 54 and tries to drop the item than the player is denied dropping that item?
if (item == Material.CHEST && player.getGameMode() == GameMode.SURVIVAL) { // } Don't use getTypeId() - no point if you can use material. Also don't cancel the event twice... why? PHP: @EventHandlerpublic void onPlayerDrop(PlayerDropItemEvent e) {Player p = e.getPlayer(); if (p.getItemInHand.getType() == Material.CHEST && p.getGameMode() == GameMode.SURVIVAL) { e.setCancelled(); p.sendMessage("You can't drop this item!");}} This should work.
Well im only using the Item Id 54 which is chest as a test function, i wnt to be able to use the ID function.
Why do you want to use ID's? They are deprecated as far as I believe because Minecraft is removing them.
Code: @EventHandler public void onPlayerDrop(PlayerDropItemEvent e) { Player p = e.getPlayer(); if (p.getItemInHand.getType().equals(Material.CHEST) && p.getGameMode().equals(GameMode.SURVIVAL)) { e.setCancelled(); p.sendMessage("You can't drop this item!"); } } Change all of your == to .equals().