Solved Find the entity, who killed a player (PlayerDeathEvent e)

Discussion in 'Plugin Development' started by InflamedSebi, Apr 3, 2013.

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

    InflamedSebi

    I'm not able to get the entity, who killed a player ...

    there is a .getLastDamageCause() where i can check for "Projectile" and "Entity_Attack"

    but how do i get this Projectile/Entity?

    .getKiller() will just return players
    e.getEntity() returns the dying player
    .getLastDamageCause() does not return a valid entity ...

    someone a better idea?
     
  2. Offline

    tehbeard

    .getLastDamageCause() returns the last damage event on the entity, check and cast as approriate.
    Code:
    EntityDamageEvent event = player.getLastDamageCause();
    if(event instanceof EntityDamageByEntityEvent){
    EntityDamageByEntityEvent eventDamage = (EntityDamageByEntityEvent) event;
     
    ... Do more things here
    }
    else
    {
    //Wasn't a projectile or entity, carry on
    }
    
     
  3. Offline

    InflamedSebi

    lol i did not know that the "EntityDamageEvent" can also be an "EntityDamageByEntityEvent"
    thanks a lot :D
     
Thread Status:
Not open for further replies.

Share This Page