Search in sources :

Example 1 with EliteExplosionEvent

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);
}
Also used : EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) Entity(org.bukkit.entity.Entity) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) EliteExplosionEvent(com.magmaguy.elitemobs.api.EliteExplosionEvent) Projectile(org.bukkit.entity.Projectile) EliteProjectile(com.magmaguy.elitemobs.combatsystem.EliteProjectile)

Aggregations

EliteExplosionEvent (com.magmaguy.elitemobs.api.EliteExplosionEvent)1 EliteProjectile (com.magmaguy.elitemobs.combatsystem.EliteProjectile)1 EliteEntity (com.magmaguy.elitemobs.mobconstructor.EliteEntity)1 Entity (org.bukkit.entity.Entity)1 Projectile (org.bukkit.entity.Projectile)1