use of com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity in project EliteMobs by MagmaGuy.
the class TreasureChest method doMimic.
private void doMimic() {
HashMap<String, Double> weighedValues = new HashMap<>();
for (String string : this.customTreasureChestConfigFields.getMimicCustomBossesList()) {
String filename = string.split(":")[0];
double weight = 1;
try {
weight = Double.valueOf(string.split(":")[1]);
} catch (Exception ex) {
weight = 1;
}
weighedValues.put(filename, weight);
}
CustomBossEntity customBossEntity = CustomBossEntity.createCustomBossEntity(WeightedProbability.pickWeighedProbability(weighedValues));
customBossEntity.spawn(location, randomizeTier(), false);
}
use of com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity in project EliteMobs by MagmaGuy.
the class TimedEvent method queueEvent.
/**
* Queues an event to start when the start conditions are met
*/
public void queueEvent() {
this.primaryEliteMobs = customSpawn.getCustomBossEntities();
setEventStartLocation(customSpawn.getSpawnLocation());
for (CustomBossEntity customBossEntity : primaryEliteMobs) if (!customBossEntity.exists()) {
if (!silentRetry) {
new InfoMessage("Boss " + customBossEntity.getCustomBossesConfigFields().getFilename() + " for event " + getCustomEventsConfigFields().getFilename() + " wasn't considered to be valid. Trying spawn again .");
new InfoMessage("Note: further failures will be silent. EliteMobs can only predict WorldGuard protections," + " so it will keep trying to spawn things until plugins preventing spawning allow it to do so. This might take a while.");
silentRetry = true;
}
Bukkit.getScheduler().runTaskLater(MetadataHandler.PLUGIN, () -> {
customSpawn.setSpawnLocation(null);
customSpawn.queueSpawn();
}, 1);
return;
}
primaryEliteMobs.forEach(CustomBossEntity::announceSpawn);
start();
}
use of com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity in project EliteMobs by MagmaGuy.
the class BossTrackingPage method bossTrackingPage.
protected static TextComponent[] bossTrackingPage(Player player) {
TextComponent configTextComponent = new TextComponent();
for (int i = 0; i < 3; i++) {
TextComponent line = new TextComponent(PlayerStatusMenuConfig.getBossTrackerTextLines()[i] + "\n");
if (!PlayerStatusMenuConfig.getBossTrackerHoverLines()[i].isEmpty())
PlayerStatusScreen.setHoverText(line, PlayerStatusMenuConfig.getBossTrackerHoverLines()[i]);
if (!PlayerStatusMenuConfig.getBossTrackerCommandLines()[i].isEmpty())
line.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, PlayerStatusMenuConfig.getBossTrackerCommandLines()[i]));
configTextComponent.addExtra(line);
}
ArrayList<TextComponent> textComponents = new ArrayList<>();
int counter = 0;
for (CustomBossEntity customBossEntity : CustomBossEntity.getTrackableCustomBosses()) {
try {
textComponents.add(SpigotMessage.commandHoverMessage(customBossEntity.getCustomBossBossBar().bossBarMessage(player, customBossEntity.getCustomBossesConfigFields().getLocationMessage()) + "\n", PlayerStatusMenuConfig.getOnBossTrackHover(), "/elitemobs trackcustomboss " + customBossEntity.getEliteUUID()));
counter++;
} catch (Exception ex) {
new WarningMessage("Failed to correctly get elements for boss tracking page!");
ex.printStackTrace();
}
}
TextComponent[] textComponent;
if (counter == 0) {
textComponent = new TextComponent[1];
textComponent[0] = configTextComponent;
} else {
textComponent = new TextComponent[(int) Math.floor(counter / 6D) + 1];
int internalCounter = 0;
textComponent[0] = configTextComponent;
for (TextComponent text : textComponents) {
int currentPage = (int) Math.floor(internalCounter / 6D);
if (textComponent[currentPage] == null)
textComponent[currentPage] = new TextComponent();
textComponent[currentPage].addExtra(text);
internalCounter++;
}
}
return textComponent;
}
use of com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity in project EliteMobs by MagmaGuy.
the class SpiritWalk method spiritWalkRegionalBossAnimation.
public static void spiritWalkRegionalBossAnimation(EliteEntity eliteEntity, Location entityLocation, Location finalLocation) {
eliteEntity.getLivingEntity().setAI(false);
eliteEntity.getLivingEntity().setInvulnerable(true);
Vector toDestination = finalLocation.clone().subtract(entityLocation.clone()).toVector().normalize().divide(new Vector(2, 2, 2));
Entity vehicle = null;
if (eliteEntity.getLivingEntity().isInsideVehicle()) {
vehicle = eliteEntity.getLivingEntity().getVehicle();
if (vehicle instanceof LivingEntity)
((LivingEntity) vehicle).setAI(false);
vehicle.setInvulnerable(true);
if (((CustomBossEntity) eliteEntity).getPhaseBossEntity() != null)
vehicle.remove();
}
new BukkitRunnable() {
final Entity vehicle = eliteEntity.getLivingEntity().getVehicle();
int counter = 0;
@Override
public void run() {
if (!eliteEntity.isValid()) {
cancel();
return;
}
if (eliteEntity.getLivingEntity().isInsideVehicle())
eliteEntity.getLivingEntity().leaveVehicle();
if (eliteEntity.getLivingEntity().getLocation().clone().distance(finalLocation) < 2 || counter > 20 * 10) {
eliteEntity.getLivingEntity().setAI(true);
eliteEntity.getLivingEntity().setInvulnerable(false);
if (vehicle != null && !vehicle.isDead())
vehicle.teleport(finalLocation);
eliteEntity.getLivingEntity().teleport(finalLocation);
if (vehicle != null && !vehicle.isDead()) {
if (vehicle instanceof LivingEntity) {
((LivingEntity) vehicle).setAI(true);
EliteEntity vehicleBoss = EntityTracker.getEliteMobEntity(vehicle);
if (vehicleBoss != null)
Bukkit.getServer().getPluginManager().callEvent(new EliteMobExitCombatEvent(vehicleBoss, EliteMobExitCombatEvent.EliteMobExitCombatReason.SPIRIT_WALK));
}
vehicle.setInvulnerable(false);
new BukkitRunnable() {
@Override
public void run() {
PreventMountExploit.bypass = true;
vehicle.addPassenger(eliteEntity.getLivingEntity());
}
}.runTaskLater(MetadataHandler.PLUGIN, 1);
}
cancel();
Bukkit.getServer().getPluginManager().callEvent(new EliteMobExitCombatEvent(eliteEntity, EliteMobExitCombatEvent.EliteMobExitCombatReason.SPIRIT_WALK));
if (eliteEntity.getLivingEntity() instanceof Mob)
if (((Mob) eliteEntity.getLivingEntity()).getTarget() == null)
eliteEntity.getLivingEntity().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 2));
}
if (vehicle != null && !vehicle.isDead()) {
vehicle.teleport(eliteEntity.getLivingEntity().getLocation().clone().add(toDestination.clone()));
}
eliteEntity.getLivingEntity().teleport(eliteEntity.getLivingEntity().getLocation().clone().add(toDestination.clone()));
counter++;
}
}.runTaskTimer(MetadataHandler.PLUGIN, 0, 1);
}
use of com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity in project EliteMobs by MagmaGuy.
the class SpawnCommand method spawnCustomBossCommand.
public static void spawnCustomBossCommand(Player player, String fileName, int level) {
CustomBossesConfigFields customBossesConfigFields = CustomBossesConfig.getCustomBoss(fileName);
if (customBossesConfigFields == null) {
player.sendMessage("Filename " + fileName + " is not valid! Make sure you are writing the name of a configuration file in the custombosses folder!");
return;
}
CustomBossEntity customBossEntity = new CustomBossEntity(customBossesConfigFields);
customBossEntity.setSpawnLocation(getLocation(player));
customBossEntity.setLevel(level);
customBossEntity.spawn(false);
}
Aggregations