Solved Force a Player to drop an Item

Discussion in 'Plugin Development' started by WavyWonderz, Oct 15, 2013.

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

    WavyWonderz

    I'm going to skip the backstory about this, I'll post it if you need.

    I want a player to drop an item as if they actually dropped it out of their hand. If I get their location and drop an item at their location, they immediately pick it back up (like when you break a block, you can pick it up immediately). This does not work for my case, because when a player drops an item normally, there is a small delay before they or another person can pick that item up, I want it to have a delay like they dropped it.

    Note. Everything I googled just tells people to drop an item at their location.
     
  2. Offline

    BungeeTheCookie

    @WavyWonders
    Drop an item at the player location, remove the item from the player inventory, and prevent the player from picking up an item for a certain time (I believe using a bukkit runnable).
     
  3. Offline

    WavyWonderz

    Meh, I guess that'd work.
     
  4. Offline

    WavyWonderz

    Btw, I was having problems with that, never got it to work, but I got another way to do it:
    Code:
    ItemStack item = player.getItemInHand();
    player.getInventory().remove(item);
    Item itemDropped = player.getWorld().dropItemNaturally(player.getLocation(), item);
    itemDropped.setPickupDelay(40);
     
Thread Status:
Not open for further replies.

Share This Page