Finding victim and attacker of EntityDamageEvent?

Discussion in 'Plugin Development' started by VilladsE, Sep 14, 2020 at 7:18 AM.

  1. Offline

    VilladsE

    How do I find the victim and attacker of a EntityDamageEvent?


    My current code:

    public void onPlayerDamage(EntityDamageEvent e) {
    if (!(e.getEntity() instanceof Player)) {
    return;
    }
    // here i want to set variable of the one attacking
    // here i want to set variable of the one being attacked
    }
     
  2. Offline

    Shqep

    EntityDamageByEntityEvent

    .getEntity() returns the one being attacked
    .getDamager() returns the one attacking
     
  3. Offline

    VilladsE

    Thanks, I was using the wrong event
     
    Shqep likes this.

Share This Page