From 38a84c9416d46423142d1716256057fc8fb12139 Mon Sep 17 00:00:00 2001 From: ulumulu1510 Date: Fri, 26 Feb 2016 18:15:39 +0100 Subject: [PATCH] 1h - Fix Arrows bouncing off entities, remove the arrow after hit. --- .../massivecraft/factions/engine/EngineMain.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/com/massivecraft/factions/engine/EngineMain.java b/src/com/massivecraft/factions/engine/EngineMain.java index 93245c79..08a04f77 100644 --- a/src/com/massivecraft/factions/engine/EngineMain.java +++ b/src/com/massivecraft/factions/engine/EngineMain.java @@ -20,6 +20,7 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.command.CommandSender; +import org.bukkit.entity.Arrow; import org.bukkit.entity.Enderman; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; @@ -790,14 +791,15 @@ public class EngineMain extends Engine // -------------------------------------------- // @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) - public void canCombatDamageHappen(EntityDamageEvent event) + public void canCombatDamageHappen(EntityDamageByEntityEvent event) { - // TODO: Can't we just listen to the class type the sub is of? - if (!(event instanceof EntityDamageByEntityEvent)) return; - EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent)event; - - if (this.canCombatDamageHappen(sub, true)) return; + if (this.canCombatDamageHappen(event, true)) return; event.setCancelled(true); + + Entity damager = event.getDamager(); + if ( ! (damager instanceof Arrow)) return; + + damager.remove(); } // mainly for flaming arrows; don't want allies or people in safe zones to be ignited even after damage event is cancelled