use of com.magmaguy.elitemobs.api.EliteExplosionEvent in project EliteMobs by MagmaGuy.
the class Explosion method generateExplosion.
private static void generateExplosion(List<Block> blockList, Entity entity, ElitePower elitePower, Location explosionSource) {
if (!DefaultConfig.isDoExplosionRegen())
return;
if (EliteMobs.worldGuardIsEnabled && explosionSource != null && !WorldGuardFlagChecker.doExplosionRegenFlag(explosionSource))
return;
ArrayList<BlockState> blockStates = new ArrayList<>();
for (Block block : blockList) {
if (block.getType().isAir() || block.getType().equals(Material.FIRE) || block.isLiquid() || EntityTracker.isTemporaryBlock(block))
continue;
nearbyBlockScan(blockStates, block.getState());
}
Entity shooter = EntityFinder.filterRangedDamagers(entity);
EliteEntity eliteEntity = null;
if (shooter != null)
eliteEntity = EntityTracker.getEliteMobEntity(shooter);
EliteExplosionEvent eliteExplosionEvent = null;
// for projectiles
if (entity instanceof Projectile) {
eliteExplosionEvent = new EliteExplosionEvent(eliteEntity, elitePower = ElitePower.getElitePower(EliteProjectile.readExplosivePower((Projectile) entity)), entity.getLocation(), blockStates);
} else {
eliteExplosionEvent = new EliteExplosionEvent(eliteEntity, elitePower, entity.getLocation(), blockStates);
}
if (eliteExplosionEvent.isCancelled())
return;
if (explosionSource != null)
eliteExplosionEvent.setExplosionSourceLocation(explosionSource);
eliteExplosionEvent.visualExplosionEffect(elitePower);
for (BlockState blockState : blockStates) {
blockState.getBlock().setType(Material.AIR);
blockState.getBlock().getState().update(true);
}
new Explosion(blockStates);
}
Aggregations