listen to EntityDamageEvent and then check if the event instance of EntityDamageByEntityEvent and check if the damage cause is projectile and you can get the entity and the damager