Solved Help with this Event

Discussion in 'Plugin Development' started by greaperc4, Sep 19, 2013.

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

    greaperc4

    So what I want here is when a player drinks a water bottle they get 20 XP levels
    There are NO errors..
    and does nothing..
    I just drink the water bottle and that's it..

    Code:java
    1. @EventHandler
    2. public void drinkpots(PlayerItemConsumeEvent event) {
    3.  
    4. Player player = event.getPlayer();
    5. ItemStack item = event.getItem();
    6. int level = player.getLevel();
    7.  
    8. if (player.getItemInHand().getType() == Material.POTION) {
    9.  
    10. player.setLevel(level+ 20);
    11. player.getInventory().removeItem(player.getItemInHand());
    12. }
    13. }


    EDIT: PEOPLE THINK ABOUT REGISTERING YOUR EVENTS
     
  2. Offline

    Chinwe

    Have you registered your listener in onEnable()?
     
  3. Offline

    greaperc4

    Thanks.. forgot it again..
    Thanks to the Awesome people here, it works now (lol)
    I will write it down EACH listener i make xD or I will forget again
     
Thread Status:
Not open for further replies.

Share This Page