Item Dropping Help

Discussion in 'Plugin Development' started by boysnnoco, Nov 6, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    boysnnoco

    I have tried many different ways to distinguish between these items so players will not be able to drop any items it keeps coming up as the last else statement and I have no idea why help plz code below:
    (Yes I have registered the events)


    @EventHandler
    public void onPlayerDrop(PlayerDropItemEvent event){

    Player player = event.getPlayer();
    if(player.hasPermission("randykit.drop")){
    return;
    }else if(player.getItemInHand().equals(Material.WRITTEN_BOOK) || player.getItemInHand().equals(Material.BOWL)){
    return;

    }else if(player.getItemInHand().equals(Material.BOOK_AND_QUILL)){
    event.setCancelled(true);
    player.sendMessage(ChatColor.DARK_RED + "RandyKits" + ChatColor.AQUA + ">" + ChatColor.RED + " Error, you must sign the book!");
    }else{
    event.setCancelled(true);
    player.sendMessage(ChatColor.DARK_RED + "RandyKits" + ChatColor.AQUA + ">" + ChatColor.RED + " Error, you don't have permission to drop that!");
    }
    }
     
  2. Offline

    vtg_the_kid

    boysnnoco
    do
    if (!player.hasPermission("randykit.drop"){
    event.setCancelled(true);
    }
     
  3. Offline

    hellboyPS

    You are comparing a ItemStack to a Material. It will always be false.
    E.g.:
    player.getItemInHand().equals(Material.WRITTEN_BOOK)
    should be
    player.getItemInHand().getType().equals(Material.WRITTEN_BOOK)

    And please use the syntax tags if you provide a longer code section like you do.
     
  4. Offline

    boysnnoco

    Thank you and sorry for not using the syntax code I was in a bit of a rush!
    Also it seems to work until say there is only 1 bowl left then it will not let you drop the item any help?

    The only thing wrong with that is I want players that do not have that permission only be able to drop Written Books and bowls (as I despawn bowls instantly).

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  5. Offline

    boysnnoco

    Solved instead of getItemInHand I did getItemDrop :)
     
Thread Status:
Not open for further replies.

Share This Page