Solved Player consume Event

Discussion in 'Plugin Development' started by xelatercero, Jun 12, 2016.

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

    xelatercero

    why this doesnt work?

    Code:
    public void onConsumeHealth(PlayerItemConsumeEvent e) {
            Player p = e.getPlayer();
            String meta = e.getItem().getItemMeta().getDisplayName();
            if(meta.equalsIgnoreCase("UP heal")) {
                p.setHealth(20);
               
               
            }
        }
     
  2. Offline

    Zombie_Striker

    @xelatercero
    1. Did you forget to add the @EventHandler tag?
    2. Are you sure item is not null?
    3. Are you sure the item has itemmeta?
    4. Are you sure the display name is equal to (ignoring case) UP, without any chatcolors?
     
    cococow123 likes this.
  3. Offline

    xelatercero

    @Zombie_Striker no i dont forget the @EventHandler... But i typed p.setHealth(0) and works, and again typed p.setHealth(20), and works.... I dont know why but Thank you, How i mark the thread as solved.

    So sorry for my english but i am russian and i have problems
     
  4. Offline

    mine-care

    Click the text under the title: "Edit thread title" or something like that, and on the left of the title choose "Solved"
     
Thread Status:
Not open for further replies.

Share This Page