use of com.magmaguy.elitemobs.mobconstructor.CustomSpawn in project EliteMobs by MagmaGuy.
the class TimedEvent method instantiateEvent.
/**
* Just because the event is instantiated, does not necessarily mean it started. If the spawn isn't instant, then
* it needs to be queued for a later date. If the spawn is instant but no valid location can be found, it should retry
* on a delay.
*/
public void instantiateEvent() {
new InfoMessage("Event " + getCustomEventsConfigFields().getFilename() + " has been queued!");
TimedEvent timedEvent = new TimedEvent(customEventsConfigFields);
CustomEventStartEvent customEventStartEvent = new CustomEventStartEvent(timedEvent);
if (customEventStartEvent.isCancelled())
return;
timedEvent.customSpawn = new CustomSpawn(customEventsConfigFields.getCustomSpawn(), customEventsConfigFields.getBossFilenames(), timedEvent);
// Failed to initialize event
if (timedEvent.customSpawn.getCustomSpawnConfigFields() == null)
return;
// This handles the elitemobs-events flag
timedEvent.customSpawn.setEvent(true);
// Note: this will finish running at an arbitrary time in the future
timedEvent.customSpawn.queueSpawn();
// global cooldown - 60 seconds right now
nextEventTrigger = System.currentTimeMillis() + globalCooldown * 60 * 1000;
timedEvents.add(timedEvent);
}
use of com.magmaguy.elitemobs.mobconstructor.CustomSpawn 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());
}
Aggregations