Explosions protect Armorstands

This commit is contained in:
BuildTools 2015-12-15 15:06:33 +01:00 committed by Olof Larsson
parent f11937efda
commit 436618324b

View File

@ -45,6 +45,7 @@ import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityCombustByEntityEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.PotionSplashEvent;
@ -1185,6 +1186,8 @@ public class EngineMain extends EngineAbstract
// FLAG: EXPLOSIONS
// -------------------------------------------- //
protected Set<DamageCause> DAMAGE_CAUSE_EXPLOSIONS = EnumSet.of(DamageCause.BLOCK_EXPLOSION, DamageCause.ENTITY_EXPLOSION);
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void blockExplosion(HangingBreakEvent event)
{
@ -1200,6 +1203,22 @@ public class EngineMain extends EngineAbstract
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void blockExplosion(EntityDamageEvent event)
{
// If an explosion damages ...
if (DAMAGE_CAUSE_EXPLOSIONS.contains(event.getCause())) return;
// ... an entity that is modified on damage ...
if ( ! MConf.get().entityTypesEditOnDamage.contains(event.getEntityType())) return;
// ... and the faction has explosions disabled ...
if (BoardColl.get().getFactionAt(PS.valueOf(event.getEntity())).isExplosionsAllowed()) return;
// ... then cancel!
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void blockExplosion(EntityExplodeEvent event)
{