Dropping Certain Items And Making Them Disappear

Discussion in 'Plugin Development' started by Brett Basinger, Mar 24, 2014.

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

    Brett Basinger

    I was looking for a code when a player drops an item, even before it drops the item is gone.
    Code:java
    1. public void onItemdrops(PlayerDropItemEvent e){
    2. Player p = e.getPlayer();
    3. if(e.getItemDrop().getItemStack().getType() == Material.BOWL);


    Is this on the right path?
     
  2. Offline

    AoH_Ruthless

    Brett Basinger
    What?

    Brett Basinger
    Instead of editing your post from "disappeared" to something worthwhile, make a new post and Tahg me (anyone) so we can see changes.

    First, you can't have a semi-colon on an if statement.
    After the if-check:

    Code:java
    1. e.getDrops().clear();


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

    MooshViolet

    Brett Basinger
    You should probably remove the semicolon and switch it with a {.
    Also do e.setCanceled(true)
     
  4. Offline

    Brett Basinger

    AoH_Ruthless thank you for the advise..... I just noticed the semi-colon mess-up. I just made the code on the spot and forgot. I will try that and notify you if it works:)

    AoH_Ruthless the
    Code:java
    1. e.getDrops().clear();

    is for if PlayerDeathEvent.......

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

    AoH_Ruthless

    Brett Basinger
    Well Damn!

    Just cancel the event:
    Code:java
    1. e.setCancelled(true);
     
  6. Offline

    Brett Basinger

    AoH_Ruthless ok, well thank you for helping me. I appreciate it.
     
    AoH_Ruthless likes this.
Thread Status:
Not open for further replies.

Share This Page