Get attacker and person attacked from event?

Discussion in 'Plugin Development' started by JazzaG, Jun 8, 2012.

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

    JazzaG

    Is it possible to get the player attacked in an EntityDamageByEntityEvent?
    I know how to get the attacker:
    Code:
    public void onAttack(EntityDamageByEntityEvent event) {
    Player attacker = null;
    Player defender = null;
    if( event.getDamager() instanceof Player ) {
    attacker = (Player)event.getDamager();
    }
    }
    
    ...but I want a way to get the person attacked, so I can do things to them >: )

    How can I go about doing this?
     
  2. Offline

    Superkabii

    Code:
    if(event.getEntity() instanceof Player) {
        defender = (Player)event.getEntity();
    }
     
    Build_and_Break and ferrybig like this.
  3. Offline

    d33k40

    Code:
    Player playeratacked = (Player) event.getEntity();
     
  4. Offline

    JazzaG

    thanks guys :)
     
Thread Status:
Not open for further replies.

Share This Page