Solved Drop Item Event not working and is registered?

Discussion in 'Plugin Development' started by MayoDwarf, Sep 22, 2013.

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

    MayoDwarf

    Code:java
    1. @EventHandler
    2. public void onPlayerDrop(PlayerDropItemEvent evt) {
    3. Player p = evt.getPlayer();
    4. if(p.getItemInHand().getType().equals(Material.RECORD_9) || p.getItemInHand().getType().equals(Material.BLAZE_ROD)) {
    5. evt.setCancelled(true);
    6. }
    7. }
     
  2. Offline

    Vandrake

    not working?Is registered? what do you mean?
     
  3. Offline

    ZeusAllMighty11

    Please don't post multiple threads with the same issue. There was already a discussion and solution on the last one.
     
  4. Offline

    MayoDwarf

    Actually it fixed one of the problems but this one was never fixed.

    And Vandrake, I mean registered the event.
    EDIT: Vandrake TheGreenGamerHD
     
  5. Offline

    Vandrake

    Then explain whats the problem here?
     
  6. did you remember too register the event into the onEnable method in your main class?
     
  7. Offline

    MayoDwarf

    I did. And the problem is that I can still drop those items in game. Why? Vandrake vxwkillerjthewalrus
     
  8. Offline

    Vandrake

    debug it, check where it's failing. I still don't get it. you registered it onEnable, implemented the Listener to the class and the eventhandler and its still letting you drop the items even though you cancelled ? is that the problem?
     
  9. MayoDwarf
    Use this instead.
    Code:java
    1. if(evt.getItemDrop().getItemStack().getType() == Material.RECORD_9 || evt.getItemDrop().getItemStack().getType() == Material.BLAZE_ROD) { }
     

  10. Hmmmmm it could be that p.getItemInHand().getType().equals(Material.RECORD_9)|| p.getItemInHand().getType().equals(Material.BLAZE_ROD)
    both are returning false or one of them is do else {

    event.setcancelled(true);
    and see what that does

    }
    botb
     
  11. Offline

    MayoDwarf

    Yah I did all that! :/ It's so weird!
     
  12. Offline

    Rockon999

    MayoDwarf
    I answered this question in your other thread :)
     
  13. Offline

    MayoDwarf

    I can't test the code tho bc mojang is down :/
     
  14. Offline

    Rockon999

  15. Offline

    MayoDwarf

    When I turn it to offline and reload or restart server it just sets online-mode to true again tho :/ wtf
     
  16. Offline

    Jade

    If you're developing, you'd have gone through the Bukkit documentation -- which would tell you how to set the server to offline mode.
     
Thread Status:
Not open for further replies.

Share This Page