[SOLVED]Event: ProjectileHit, Need Help

Discussion in 'Plugin Development' started by Raldo94, Jul 18, 2012.

Thread Status:
Not open for further replies.
  1. Im trying to block a player from shooting arrows at another player. But i cant figure it out.
    Did find something smilar but it was verry old, so useless.
    I dont know how the get the Arrow nor the player(if) it hits.
    Could any one else help me out?

    ps. My ENG is not so good
     
  2. Offline

    theguynextdoor

    Try using an EntityDamageByEntityEvent and then checking if e.getEntity() is a player, and then if the damager of the event is a projectile and then if the shooter of that projectile is a player. This event will only be called if the arrow hits the player so you dont have to worry about misses or anything. Here is the link to the java doc for the event: http://jd.bukkit.org/doxygen/df/d06...yEvent.html#a311a3b7e7cc29ece9a5da1142a68c444
     
    ferrybig and Raldo94 like this.
  3. make a new ProjectleHitEvent. set it so that if the entity is a player, cancel it
     
  4. Thx for the help, Got it to work
    Forgot i had food on the stoove :/, Gonna fix the part of the check of the player a bit later :)
    Code:
    if (e.getEntity() instanceof Player) {
                    if (e.getDamager() instanceof Arrow) {
                        e.setCancelled(true);
                       
                    }
                   
                }
     
Thread Status:
Not open for further replies.

Share This Page