Solved PlayerPickupItemEvent wont fire

Discussion in 'Plugin Development' started by King V, Mar 27, 2016.

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

    King V

    title has it all, aditiona info:
    i have registered the eventhandler and other eventhandlers in the class work.

    code:
    @EventHandler
    public void onPickup(PlayerPickupItemEvent event) {
    System.out.println("t1");
    Player player = event.getPlayer();
    // Entity entity = event.getItem();
    Arrow entity = (Arrow) event.getItem();
    //Arrow entity = event.getArrow();
    System.out.println("pickup:"+entity);
    if(entity.hasMetadata("water_arrow")) {
    Main.waterarrow.remove(entity);
    System.out.println("remove water:"+entity);
    }
    if(entity.hasMetadata("fire_arrow")) {
    Main.firearrow.remove(entity);
    System.out.println("remove fire:"+entity);
    }
    if(entity.hasMetadata("cloud_arrow")) {
    Main.cloudarrow.remove(entity);
    System.out.println("remove cloud:"+entity);
    }
    }
     
  2. Offline

    Corndogoz

    can we see the other class?
     
  3. Offline

    mcdorli

    Errors?

    You shouldn't abuse static
     
  4. Offline

    mine-care

    Dont blind cast!!!
    and also, is the debug message showing?
     
  5. Offline

    King V

    (Sent on mobile I'm in a car) no, the debug message doesn't show up

    It doesn't really matter since it never happens since the event handler isnt working. The "t1" never prints. Other event handlers in the same class work and are called.

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

    WolfMage1

    then the event's not registered.
     
  7. Offline

    King V

    The other event handlers in the class work, it is registered. Or do I have to do something extra
     
  8. Offline

    mcdorli

    Try to set it, so it ignores cancelled events
     
  9. Offline

    King V

    thanks everyone for the help, i got it to work!
     
Thread Status:
Not open for further replies.

Share This Page