Help With Item Drop

Discussion in 'Plugin Development' started by Jedodalci, Sep 21, 2014.

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

    Jedodalci

    I Create a PlayerDropItemEvent and i Block the Drop with event.setCancelled(true);
    But i Have a Problem....
    When Player Drop an Item isn't Drop But It Moves in the Inventory.
    How do I not let it move inventory?
    Help Me
     
  2. Offline

    Mr_toaster111

    can you post your code?
     
  3. Offline

    Jedodalci

    @EventHandler
    public void on(PlayerDropItemEvent e) {
    if (!e.getPlayer().isOp()) {
    if (e.getPlayer().getItemInHand() != null) {
    e.setCancelled(true);
    e.getPlayer().sendMessage(this.prefix + " §aNon puoi Droppare Item a Terra nella Hub!");
    }

    }

    }
     
  4. Offline

    DusRonald

    Jedodalci

    Tips:
    1. Please paste your code in a code tag...
    2. You could use: (Clean Way)
      Code:java
      1. if(!e.getPlayer().isOp()) return;
    3. You could add:
      Code:java
      1. if(e.getPlayer().getItemInHand() == null) return;
    4. Some code under the code above that.
    Key tips:
    1. CTRL + SHIFT + F = Format code. (Eclipse).
    2. CTRL + SHIFT + O = Import. (Eclipse).
    Solution:
    Code:java
    1. e.setCancelled(true);
    2. e.getItem().setSlot(e.getItem().getSlot());
     
  5. Offline

    Jedodalci


    e.getItem doesn't exist in PlayerDropItemEvent....
     
  6. Offline

    DusRonald

    Jedodalci I have that written without IDE.
    I don't know what the true method is. You must explain that.
    Search to a method like that.
     
Thread Status:
Not open for further replies.

Share This Page