Player shoot arrow event?

Discussion in 'Plugin Development' started by JjPwN1, Oct 9, 2012.

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

    JjPwN1

    I am trying to use ProjectileHitEvent to block shooting arrows at your teammate. But, with the ProjectileHitEvent I can't get the shooter, only the entity it's hitting, so I can't see if the shooter is on the same team as the one getting hit. So, my question is, how do you do this?
     
  2. Offline

    Courier

    ProjectileHitEvent.getEntity().getShooter()

    However, ProjectileHitEvent is only fired when the projectile hits a block, not an entity.
    I believe you need to listen to EntityDamageByEntityEvent, and if the damage-cause is a projectile, you can call ((Projectile)EntityDamageByEntityEvent.getDamager()).getShooter()
     
    V10lator likes this.
  3. What Courier told. But make sure that getShooter() isn't null (arrow shooted from dispenser or plugin) and a instance of Player (arrow shooted from skeleton or plugin).
     
    Courier likes this.
Thread Status:
Not open for further replies.

Share This Page