Disable health regeneration?

Discussion in 'Plugin Development' started by Mattz, Mar 12, 2013.

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

    Mattz

    How can I disable health regeneration for specific players, but they can still use items such as potions to regain health?
     
  2. Offline

    TheUpdater

    p.gethealth
    p.sethealtregenation(false);
    p.sendmessage(Y N Regenation);

    xD try that

    trololololol
     
  3. Offline

    Mattz

    There aren't any such methods in the Player class?
     
  4. Offline

    TheUpdater

    dont you see trololol xD

    i will try find it wait xD haha

    cant find it dont think its possible lol

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  5. Offline

    microgeek

    Cancel EntityRegainHealthEvent?
     
  6. Offline

    Mattz

    Thanks, this works.

    One problem though, how can I still enable health regeneration effects from potions and golden apples?
     
  7. Offline

    TheUpdater

    make an id whit golden appels and potions

    whit playerinteractEvevent

    i will post exampel wait

    @EventHandler
    public void onPlayerInteract1(PlayerInteractEvent e){
    if ((e.getAction() == Action.RIGHT_CLICK_BLOCK)) {
    e.getClickedBlock().getType().getId();{
    Material Blockid = Material.<apple id>;
    if(Blockid == Material.<apple id){
    Cancel EntityRegainHealthEvent(faslse);
    @EventHandler
    public void onPlayerInteract1(PlayerInteractEvent e){
    if ((e.getAction() == Action.RIGHT_CLICK_BLOCK)) {
    e.getClickedBlock().getType().getId();{
    Material Blockid = Material.<hand>;
    if(Blockid == Material.<hand<{
    Cancel EntityRegainHealthEvent(true);
    }
    }
    }
    }


    this is not correct code but kind off tell me if dont understand

    it means if have apple in hand and eat it it will set it to true
    when you have eat up hand is big ways always comming up after then it sets it to true
    lol...

    OBS not correct code befor you post any ban comments it an exampel

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  8. Offline

    AmShaegar

    Much easier: Just disable health regen from certain sources:

    Code:
        @EventHandler
        public void onPlayerRegainHealth(EntityRegainHealthEvent event) {
            if(event.getRegainReason() == RegainReason.SATIATED || event.getRegainReason() == RegainReason.REGEN)
                event.setCancelled(true);
        }
     
Thread Status:
Not open for further replies.

Share This Page