How do I get the damager in EntityDamageEvent? I tried: PHP: if($entity->getLastDamageCause() instanceof EntityDamageByEntityEvent){ $damager = $entity->getLastDamageCause()->getDamager(); if($damager instanceof Player){ $damager->sendMessage("Hi"); }} but it didnt work, no errors or anything. But PhpStorm says getDamager() isn't a thing, but it is in EntityDamageByEntityEvent. Can someone help me out?
What have you tried in debugging this? Have you tried to verify if either of the if loops executes? Also, you don't need to use getLastDamageCause() if you are currently handling a EntityDamageEvent.
PHP: if($event instanceof EntityDamageByEntityEvent){ $damager = $event->getDamager(); if($damager instanceof Player){ $damager->sendMessage("Hi"); }}