diff --git a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/entity/ShootCommand.java b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/entity/ShootCommand.java index 59d22bb806..34c08691ab 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/entity/ShootCommand.java +++ b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/entity/ShootCommand.java @@ -376,23 +376,26 @@ else if (lastLocation != null && lastVelocity != null && !(lastEntity.getBukkitE @EventHandler public void projectileHit(ProjectileHitEvent event) { - arrows.remove(event.getEntity().getUniqueId()); + if (!arrows.containsKey(event.getEntity().getUniqueId())) { + return; + } + if (event.getHitEntity() != null) { + arrows.put(event.getEntity().getUniqueId(), new EntityTag(event.getHitEntity())); + } + else { + arrows.remove(event.getEntity().getUniqueId()); + } } @EventHandler public void arrowDamage(EntityDamageByEntityEvent event) { - // Get the damager Entity arrow = event.getDamager(); - // First, quickly confirm it's a projectile (relevant at all) if (!(arrow instanceof Projectile)) { return; } - // Second, more slowly check if we shot it if (!arrows.containsKey(arrow.getUniqueId())) { return; } - // Replace its entry with the hit entity. - arrows.remove(arrow.getUniqueId()); arrows.put(arrow.getUniqueId(), new EntityTag(event.getEntity())); } }