1h - Fix Arrows bouncing off entities, remove the arrow after hit.

This commit is contained in:
ulumulu1510 2016-02-26 18:15:39 +01:00 committed by Olof Larsson
parent 9a3b472e96
commit 38a84c9416

View File

@ -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