Search in sources :

Example 11 with EliteEntity

use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.

the class EntityTracker method unregisterEliteEntity.

public static void unregisterEliteEntity(Entity entity, RemovalReason removalReason) {
    EliteEntity eliteEntity = getEliteMobEntity(entity);
    if (eliteEntity == null)
        return;
    // Removal from the hashmap is not guaranteed here as some forms of removal don't completely wipe the elite entity out
    eliteEntity.remove(removalReason);
}
Also used : EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity)

Example 12 with EliteEntity

use of com.magmaguy.elitemobs.mobconstructor.EliteEntity 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)

Example 13 with EliteEntity

use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.

the class VisualEffectObfuscator method onDamageByPlayer.

@EventHandler
public void onDamageByPlayer(EntityDamageByEntityEvent event) {
    if (!(EntityFinder.getRealDamager(event) instanceof Player))
        return;
    EliteEntity eliteEntity = EntityTracker.getEliteMobEntity(event.getEntity());
    if (eliteEntity == null)
        return;
    eliteEntity.setVisualEffectObfuscated(false);
}
Also used : Player(org.bukkit.entity.Player) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) EventHandler(org.bukkit.event.EventHandler)

Example 14 with EliteEntity

use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.

the class EntityTracker method wipeShutdown.

public static void wipeShutdown() {
    for (EliteEntity eliteEntity : ((HashMap<UUID, EliteEntity>) eliteMobEntities.clone()).values()) eliteEntity.remove(RemovalReason.SHUTDOWN);
    getEliteMobEntities().clear();
    for (NPCEntity npcEntity : ((HashMap<UUID, NPCEntity>) npcEntities.clone()).values()) npcEntity.remove(RemovalReason.SHUTDOWN);
    getNpcEntities().clear();
    for (Block block : temporaryBlocks) block.setType(Material.AIR);
    temporaryBlocks.clear();
    // Necessary for things such as visual effects which are not stored in memory, only tagged
    for (World world : Bukkit.getWorlds()) for (Entity entity : world.getEntities()) unregister(entity, RemovalReason.SHUTDOWN);
    SimplePersistentEntity.getPersistentEntities().clear();
    CustomBossEntity.getTrackableCustomBosses().clear();
    CrashFix.knownSessionChunks.clear();
}
Also used : EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) SimplePersistentEntity(com.magmaguy.elitemobs.mobconstructor.SimplePersistentEntity) NPCEntity(com.magmaguy.elitemobs.npcs.NPCEntity) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) NPCEntity(com.magmaguy.elitemobs.npcs.NPCEntity) Block(org.bukkit.block.Block) World(org.bukkit.World)

Example 15 with EliteEntity

use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.

the class ChannelHealing method doPower.

private void doPower(EliteEntity eliteEntity) {
    for (Entity entity : eliteEntity.getLivingEntity().getNearbyEntities(20, 20, 20)) {
        EliteEntity parsedEntity = EntityTracker.getEliteMobEntity(entity);
        if (parsedEntity == null)
            continue;
        if (parsedEntity.getHealth() / parsedEntity.getMaxHealth() > .8)
            continue;
        channelHealing(eliteEntity, parsedEntity);
        return;
    }
}
Also used : Entity(org.bukkit.entity.Entity) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity)

Aggregations

EliteEntity (com.magmaguy.elitemobs.mobconstructor.EliteEntity)29 Entity (org.bukkit.entity.Entity)16 LivingEntity (org.bukkit.entity.LivingEntity)12 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)10 EventHandler (org.bukkit.event.EventHandler)8 Vector (org.bukkit.util.Vector)8 CustomBossEntity (com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)7 Location (org.bukkit.Location)7 Player (org.bukkit.entity.Player)6 ArrayList (java.util.ArrayList)3 Block (org.bukkit.block.Block)3 RegionalBossEntity (com.magmaguy.elitemobs.mobconstructor.custombosses.RegionalBossEntity)2 ElitePower (com.magmaguy.elitemobs.powers.meta.ElitePower)2 PotionEffect (org.bukkit.potion.PotionEffect)2 ChatColorConverter.convert (com.magmaguy.elitemobs.ChatColorConverter.convert)1 MetadataHandler (com.magmaguy.elitemobs.MetadataHandler)1 EliteExplosionEvent (com.magmaguy.elitemobs.api.EliteExplosionEvent)1 EliteMobDamagedByPlayerEvent (com.magmaguy.elitemobs.api.EliteMobDamagedByPlayerEvent)1 EliteMobExitCombatEvent (com.magmaguy.elitemobs.api.EliteMobExitCombatEvent)1 EliteProjectile (com.magmaguy.elitemobs.combatsystem.EliteProjectile)1