Removing Entity after Player death

Discussion in 'Plugin Development' started by Pr0_fAssEr, Mar 7, 2015.

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

    Pr0_fAssEr

    I want to remove entity(Wolf) when the owner of the wolf dies.

    I Tryed like 10 codes and noone works please can you help me ?
     
  2. Offline

    Signatured

    What have you tried? We don't want to give you code that you've already attempted before being.
     
  3. Offline

    Pr0_fAssEr

    Last edited by a moderator: Mar 7, 2015
  4. Offline

    MaTaMoR_

    Try adding some debug messages.
     
  5. Offline

    Pr0_fAssEr

  6. Offline

    RROD

    p.getWorld().getEntitiesByClass(Wolf.class) will get every Wolf entity in the world.

    Therefore, you want to do something like this inside your event method.

    Code:
    for (Wolf wolf : p.getWorld().getEntitiesByClass(Wolf.class)) {
        // If the wolf isn't tamed, or the wolf does not belong to the player that died, then continue
        if (!wolf.isTamed() || !wolf.getOwner().equals(p)) continue;
    
        // So the code here will only execute if the above statement returns true
        wolf.remove();
    }
    
     
Thread Status:
Not open for further replies.

Share This Page