Eat Food Then Get Healed

Discussion in 'Spigot Plugin Development' started by Kadioshi, May 7, 2015.

Thread Status:
Not open for further replies.
  1. I'm coding this plugin, I'm wondering how I would when I eat food I want it to be able to give me health. How would I do this?
    • Agree Agree x 1
  2. Just use player.setHealth(20D); using PlayerItemConsumeEvent. :)
  3. Hey, I have two questions;
    How can I make myself COMPLETLY invisible to other players using the PlayerItemConsumeEvent, and
    how would I add health using the PlayerItemConsumeEvent?
  4. I mean Add like 3hearts to your existing health.
  5. Juste do :
    Code (Text):
    Player p ;

    int currentLife = p.getHealth();
    p.setHealth(currentLife + 3);
    • Agree Agree x 1
  6. Do you want to add health INSTEAD of filling up hunger or do you want the hunger to be filled up as usual?
    Do you want the amount of health added DEPEND on the amount of hunger filled by the food consumed, or do you want a set specific amount every single time no matter what you eat?
    Do you want to HEAL damaged hearts, or do you want to ADD new extra hearts?
    If extra hearts > Do you want to PERMANENTLY add hearts or do you want to add health boost EFFECT?
  7. When a player gets heart have the ability to add hearts to the current health. And no not Permanently
  8. It dosen't work?
  9. Your answer is so impossibly vague, you didn't answer half my questions.
    When a player get hearts.
    Have the abililty > What do you mean have the ability?
    Add hearts to current health > Heal OR Extra hearts?
    How many hearts? Does it depend on the food?
    Do you still want hunger to fill up when they eat food?
  10. It should work! Check if your player object isn't null.
  11. Hum I coded this :
    Code (Text):
        public void onItemConsume(PlayerItemConsumeEvent e){
            Player p = e.getPlayer();
            Damageable d = (Damageable) p;
            double life = d.getHealth();
            p.setHealth(life + 3);
    not tested..
  12. gigosaurus


    Clarify what exactly you are after and then we might be able to help.
Thread Status:
Not open for further replies.