Solved OnFLevelChange

Discussion in 'Plugin Development' started by MordorKing78, Nov 12, 2014.

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

    MordorKing78

    So what I'm trying to do is when player eats a gold carrot..

    Then A message will be send.

    This is what I tried
    Code:java
    1. @EventHandler
    2. public void onFoodLevelChange(final FoodLevelChangeEvent e) {
    3. if (e.getEntity() instanceof Player) {
    4. Player p = (Player)e.getEntity();
    5. ItemStack food = e.getEntity().getItemInHand();
    6.  
    7. if(food.getType().name().equals(Material.GOLDEN_CARROT)){
    8. p.sendMessage("You ate a carror gold");
    9. }
    10. }
    11. }
     
  2. Offline

    drpk

    MordorKing78 you're trying to compare a string and a Material.
     
  3. Offline

    MordorKing78

    drpk *facepalm mode* = Activated
     
  4. Offline

    drpk

    MordorKing78 lol, we all make mistakes. I wouldn't have caught it if IntelliJ hadn't warned me about it.
     
    MordorKing78 likes this.
  5. Offline

    _Filip

    Compare enums with == it's more readable
     
Thread Status:
Not open for further replies.

Share This Page