Im using the EntityHitByEntityEvent but whenever I get shot by an arrow It doesnt perform the command (probably because the arrow is the entity I was hit by). So my question is, how do you get the shooter of an arrow in this event? Thanks for any help
First of all, it's 'EntityDamageByEntityEvent'. Check to see if the damaged entity is a player Code: if (!(event.getEntity instanceof Player)) return; Player player = (Player) event.getEntity(); then see if the player was damaged by a projectile and then specify arrow Code: if (!(event.getDamager() instanceof Projectile)) return; Projectile proj = (Projectile) event.getDamager(); if (!(proj instanceof Arrow)) return; (You may be able to skip checking for Projectile and just directly check for Arrow) Then check to see if the shooter is a player. Code: if (!(proj.getShooter() instanceof Player)) return; Player shooter = (Shooter) proj.getShooter(); and now you have your shooter.
Yeah, Silly me thats what I meant. Also, Thanks for the help. Eballer48 I have another question. It is unrelated but im not sure about something. So if i wanted to check when a player hits a block. Would I use EntityDamageByBlockEvent? Or is there another event to use in that situation EDIT by Moderator: merged posts, please use the edit button instead of double posting.
When you just click (hit) a block? It's PlayerInteractEvent. When you break a block? BlockBreakEvent.
Eballer48 No. Like when a player falls from the sky and hits the block beneath them and gets fall damage.
Eballer48 Also, if you have time and/or want to, I'd love to have some help with this issue http://forums.bukkit.org/threads/pitch-and-yaw.282081/ If not I understand and I really appreciate your help so far.