Search in sources :

Example 1 with SimplePersistentEntity

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

the class NPCEntity method worldUnload.

@Override
public void worldUnload() {
    spawnLocation = null;
    simplePersistentEntity = new SimplePersistentEntity(this);
    remove(RemovalReason.WORLD_UNLOAD);
}
Also used : SimplePersistentEntity(com.magmaguy.elitemobs.mobconstructor.SimplePersistentEntity)

Example 2 with SimplePersistentEntity

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

the class NPCEntity method remove.

public void remove(RemovalReason removalReason) {
    if (roleDisplay != null)
        roleDisplay.remove();
    if (villager != null) {
        villager.remove();
        EntityTracker.getNpcEntities().remove(villager.getUniqueId());
        this.villager = null;
    }
    if (removalReason.equals(RemovalReason.CHUNK_UNLOAD)) {
        simplePersistentEntity = new SimplePersistentEntity(this);
    }
    boolean permanentRemoval = false;
    if (removalReason.equals(RemovalReason.REMOVE_COMMAND))
        npCsConfigFields.setEnabled(false);
    if (removalReason.equals(RemovalReason.WORLD_UNLOAD) || removalReason.equals(RemovalReason.REMOVE_COMMAND))
        permanentRemoval = true;
    if (permanentRemoval)
        spawnLocation = null;
}
Also used : SimplePersistentEntity(com.magmaguy.elitemobs.mobconstructor.SimplePersistentEntity)

Example 3 with SimplePersistentEntity

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

the class CustomBossEntity method remove.

@Override
public void remove(RemovalReason removalReason) {
    bossTrace.setRemove(removalReason);
    if (DebugMessage.isDebugMode())
        if (this instanceof RegionalBossEntity && this.phaseBossEntity != null)
            new DebugMessage("Regional + Phase boss removal. Reason: " + removalReason);
    if (livingEntity != null)
        persistentLocation = livingEntity.getLocation();
    // Remove the living entity
    super.remove(removalReason);
    // Remove things tied to the living entity
    if (customBossTrail != null)
        customBossTrail.terminateTrails();
    if (livingEntityMount != null)
        livingEntityMount.remove();
    if (customBossMount != null)
        customBossMount.remove(RemovalReason.REINFORCEMENT_CULL);
    if (customBossesConfigFields.isCullReinforcements() || removalReason.equals(RemovalReason.PHASE_BOSS_RESET))
        cullReinforcements(false);
    if (removalReason.equals(RemovalReason.PHASE_BOSS_PHASE_END))
        if (inCombat)
            new EventCaller(new EliteMobExitCombatEvent(this, EliteMobExitCombatEvent.EliteMobExitCombatReason.PHASE_SWITCH));
    boolean bossInstanceEnd = removalReason.equals(RemovalReason.KILL_COMMAND) || removalReason.equals(RemovalReason.DEATH) || removalReason.equals(RemovalReason.BOSS_TIMEOUT) || removalReason.equals(RemovalReason.WORLD_UNLOAD) || removalReason.equals(RemovalReason.SHUTDOWN);
    if (!isPersistent)
        bossInstanceEnd = true;
    if (bossInstanceEnd) {
        if (!(this instanceof RegionalBossEntity))
            EntityTracker.getEliteMobEntities().remove(super.eliteUUID);
        new EventCaller(new EliteMobRemoveEvent(this, removalReason));
        if (escapeMechanism != null)
            Bukkit.getScheduler().cancelTask(escapeMechanism);
        trackableCustomBosses.remove(this);
        if (simplePersistentEntity != null) {
            simplePersistentEntity.remove();
            simplePersistentEntity = null;
        }
        if (customBossBossBar != null)
            customBossBossBar.remove();
        if (!removalReason.equals(RemovalReason.SHUTDOWN) && !removalReason.equals(RemovalReason.DEATH))
            if (phaseBossEntity != null)
                phaseBossEntity.silentReset();
        globalReinforcements.forEach((bukkitTask -> {
            if (bukkitTask != null)
                bukkitTask.cancel();
        }));
        globalReinforcements.clear();
        if (!removalReason.equals(RemovalReason.REINFORCEMENT_CULL)) {
            if (summoningEntity != null)
                summoningEntity.removeReinforcement(this);
            if (customSpawn != null)
                customSpawn.setKeepTrying(false);
        }
        if (isPersistent && removalReason.equals(RemovalReason.WORLD_UNLOAD)) {
            // if the world unloads, the location objects cease to be valid
            spawnLocation.setWorld(null);
            persistentLocation = spawnLocation;
            simplePersistentEntity = new SimplePersistentEntity(this, spawnLocation);
        }
        if (customBossesConfigFields.isCullReinforcements())
            cullReinforcements(true);
    } else if (removalReason.equals(RemovalReason.CHUNK_UNLOAD))
        // when bosses get removed due to chunk unloads and are persistent they should remain stored
        simplePersistentEntity = new SimplePersistentEntity(this, getLocation());
}
Also used : Setter(lombok.Setter) DefaultConfig(com.magmaguy.elitemobs.config.DefaultConfig) ElitePlayerInventory(com.magmaguy.elitemobs.playerdata.ElitePlayerInventory) Getter(lombok.Getter) CustomBossesConfig(com.magmaguy.elitemobs.config.custombosses.CustomBossesConfig) CustomEvent(com.magmaguy.elitemobs.events.CustomEvent) CustomBossesConfigFields(com.magmaguy.elitemobs.config.custombosses.CustomBossesConfigFields) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) Player(org.bukkit.entity.Player) MobCombatSettingsConfig(com.magmaguy.elitemobs.config.MobCombatSettingsConfig) CustomSummonPower(com.magmaguy.elitemobs.powers.meta.CustomSummonPower) ArrayList(java.util.ArrayList) EventHandler(org.bukkit.event.EventHandler) HashSet(java.util.HashSet) EliteMobProperties(com.magmaguy.elitemobs.mobconstructor.mobdata.aggressivemobs.EliteMobProperties) DisguiseEntity(com.magmaguy.elitemobs.thirdparty.libsdisguises.DisguiseEntity) Location(org.bukkit.Location) Minidungeon(com.magmaguy.elitemobs.dungeons.Minidungeon) MetadataHandler(com.magmaguy.elitemobs.MetadataHandler) com.magmaguy.elitemobs.utils(com.magmaguy.elitemobs.utils) Material(org.bukkit.Material) Nullable(javax.annotation.Nullable) EliteMobEnterCombatEvent(com.magmaguy.elitemobs.api.EliteMobEnterCombatEvent) Bukkit(org.bukkit.Bukkit) Listener(org.bukkit.event.Listener) EventsConfig(com.magmaguy.elitemobs.config.EventsConfig) RemovalReason(com.magmaguy.elitemobs.api.internal.RemovalReason) Entity(org.bukkit.entity.Entity) CreatureSpawnEvent(org.bukkit.event.entity.CreatureSpawnEvent) EliteMobExitCombatEvent(com.magmaguy.elitemobs.api.EliteMobExitCombatEvent) ElitePower(com.magmaguy.elitemobs.powers.meta.ElitePower) SimplePersistentEntityInterface(com.magmaguy.elitemobs.mobconstructor.SimplePersistentEntityInterface) EntityTracker(com.magmaguy.elitemobs.entitytracker.EntityTracker) LivingEntity(org.bukkit.entity.LivingEntity) SimplePersistentEntity(com.magmaguy.elitemobs.mobconstructor.SimplePersistentEntity) TransitiveBlock(com.magmaguy.elitemobs.mobconstructor.custombosses.transitiveblocks.TransitiveBlock) Objects(java.util.Objects) List(java.util.List) CustomModel(com.magmaguy.elitemobs.thirdparty.modelengine.CustomModel) DiscordSRVAnnouncement(com.magmaguy.elitemobs.thirdparty.discordsrv.DiscordSRVAnnouncement) BukkitTask(org.bukkit.scheduler.BukkitTask) CustomSpawn(com.magmaguy.elitemobs.mobconstructor.CustomSpawn) ChatColorConverter(com.magmaguy.elitemobs.ChatColorConverter) EliteMobRemoveEvent(com.magmaguy.elitemobs.api.EliteMobRemoveEvent) PotionEffectType(org.bukkit.potion.PotionEffectType) SimplePersistentEntity(com.magmaguy.elitemobs.mobconstructor.SimplePersistentEntity) EliteMobRemoveEvent(com.magmaguy.elitemobs.api.EliteMobRemoveEvent) EliteMobExitCombatEvent(com.magmaguy.elitemobs.api.EliteMobExitCombatEvent)

Aggregations

SimplePersistentEntity (com.magmaguy.elitemobs.mobconstructor.SimplePersistentEntity)3 ChatColorConverter (com.magmaguy.elitemobs.ChatColorConverter)1 MetadataHandler (com.magmaguy.elitemobs.MetadataHandler)1 EliteMobEnterCombatEvent (com.magmaguy.elitemobs.api.EliteMobEnterCombatEvent)1 EliteMobExitCombatEvent (com.magmaguy.elitemobs.api.EliteMobExitCombatEvent)1 EliteMobRemoveEvent (com.magmaguy.elitemobs.api.EliteMobRemoveEvent)1 RemovalReason (com.magmaguy.elitemobs.api.internal.RemovalReason)1 DefaultConfig (com.magmaguy.elitemobs.config.DefaultConfig)1 EventsConfig (com.magmaguy.elitemobs.config.EventsConfig)1 MobCombatSettingsConfig (com.magmaguy.elitemobs.config.MobCombatSettingsConfig)1 CustomBossesConfig (com.magmaguy.elitemobs.config.custombosses.CustomBossesConfig)1 CustomBossesConfigFields (com.magmaguy.elitemobs.config.custombosses.CustomBossesConfigFields)1 Minidungeon (com.magmaguy.elitemobs.dungeons.Minidungeon)1 EntityTracker (com.magmaguy.elitemobs.entitytracker.EntityTracker)1 CustomEvent (com.magmaguy.elitemobs.events.CustomEvent)1 CustomSpawn (com.magmaguy.elitemobs.mobconstructor.CustomSpawn)1 EliteEntity (com.magmaguy.elitemobs.mobconstructor.EliteEntity)1 SimplePersistentEntityInterface (com.magmaguy.elitemobs.mobconstructor.SimplePersistentEntityInterface)1 TransitiveBlock (com.magmaguy.elitemobs.mobconstructor.custombosses.transitiveblocks.TransitiveBlock)1 EliteMobProperties (com.magmaguy.elitemobs.mobconstructor.mobdata.aggressivemobs.EliteMobProperties)1