use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class CustomSummonPower method addEntry.
public void addEntry(String powerString) {
// this is now considered to be legacy
if (powerString.split(":")[0].equalsIgnoreCase("summon")) {
if (powerString.split(":")[1].equalsIgnoreCase("once"))
parseOnce(powerString);
else if (powerString.split(":")[1].equalsIgnoreCase("onHit"))
parseOnHit(powerString);
else if (powerString.split(":")[1].equalsIgnoreCase("onCombatEnter"))
parseOnCombatEnter(powerString);
else if (powerString.split(":")[1].equalsIgnoreCase("onCombatEnterPlaceCrystal"))
parseOnCombatEnterPlaceCrystal(powerString);
}
// this is the new recommended format for reinforcements
if (powerString.split(":")[0].equalsIgnoreCase("summonable")) {
SummonType summonType = null;
String filename = null;
Vector location = null;
Double chance = null;
boolean lightningRod = false;
boolean inheritAggro = false;
boolean inheritLevel = false;
String customSpawn = "";
int amount = 1;
boolean spawnNearby = false;
for (String substring : powerString.split(":")) {
switch(substring.split("=")[0].toLowerCase()) {
// this just tags it for parsing
case "summonable":
break;
case "summontype":
try {
summonType = SummonType.valueOf(getSubstringField(substring));
} catch (Exception ex) {
new WarningMessage("Failed to determine summon type from " + getSubstringField(substring));
}
break;
case "filename":
try {
filename = getSubstringField(substring);
} catch (Exception ex) {
new WarningMessage("Failed to determine filename from " + getSubstringField(substring));
}
break;
case "chance":
try {
chance = Double.parseDouble(getSubstringField(substring));
} catch (Exception ex) {
new WarningMessage("Failed to determine chance from " + getSubstringField(substring));
}
break;
case "location":
try {
String locationString = getSubstringField(substring);
location = new Vector(Double.parseDouble(locationString.split(",")[0]), Double.parseDouble(locationString.split(",")[1]), Double.parseDouble(locationString.split(",")[2]));
} catch (Exception ex) {
new WarningMessage("Failed to determine location from " + getSubstringField(substring));
}
break;
case "lightningrod":
try {
lightningRod = Boolean.parseBoolean(getSubstringField(substring));
} catch (Exception ex) {
new WarningMessage("Failed to determine lightningRod from " + getSubstringField(substring));
}
break;
case "inheritaggro":
try {
inheritAggro = Boolean.parseBoolean(getSubstringField(substring));
} catch (Exception ex) {
new WarningMessage("Failed to determine inheritAggro from " + getSubstringField(substring));
}
break;
case "amount":
try {
amount = Integer.parseInt(getSubstringField(substring));
} catch (Exception ex) {
new WarningMessage("Failed to determine inheritAggro from " + getSubstringField(substring));
}
break;
case "inheritlevel":
try {
inheritLevel = Boolean.parseBoolean(getSubstringField(substring));
} catch (Exception ex) {
new WarningMessage("Failed to determine inheritLevel from " + getSubstringField(substring));
}
break;
case "spawnnearby":
try {
spawnNearby = Boolean.parseBoolean(getSubstringField(substring));
} catch (Exception ex) {
new WarningMessage("Failed to determine spawnNearby from " + getSubstringField(substring));
}
break;
case "customspawn":
if (CustomSpawnConfig.getCustomEvent(getSubstringField(substring)) == null)
new WarningMessage("Failed to determine Custom Spawn file for filename " + substring);
else
customSpawn = getSubstringField(substring);
break;
default:
new WarningMessage("Invalid boss reinforcement string for line " + powerString + " !");
new WarningMessage("Problematic entry: " + substring);
}
}
if (summonType == null) {
new WarningMessage("No summon type detected in " + powerString + " ! This reinforcement will not work.");
return;
}
CustomBossReinforcement customBossReinforcement;
switch(summonType) {
case ONCE:
customBossReinforcement = doOnce(filename);
break;
case ON_HIT:
customBossReinforcement = doOnHit(filename, chance);
break;
case ON_DEATH:
customBossReinforcement = doOnDeath(filename);
break;
case ON_COMBAT_ENTER:
customBossReinforcement = doOnCombatEnter(filename);
break;
case ON_COMBAT_ENTER_PLACE_CRYSTAL:
customBossReinforcement = doOnCombatEnterPlaceCrystal(location, lightningRod);
break;
case GLOBAL:
customBossReinforcement = doGlobalSummonReinforcement(filename);
break;
default:
customBossReinforcement = null;
new WarningMessage("Failed to determine summon type for reinforcement " + powerString + " ! Contact the developer with this error!");
}
if (customBossReinforcement == null)
return;
customBossReinforcement.inheritAggro = inheritAggro;
customBossReinforcement.amount = amount;
customBossReinforcement.inheritLevel = inheritLevel;
customBossReinforcement.spawnNearby = spawnNearby;
customBossReinforcement.customSpawn = customSpawn;
customBossReinforcement.summonChance = chance;
customBossReinforcement.setSpawnLocationOffset(location);
}
}
use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class CustomSummonPower method doGlobalSummonReinforcement.
private CustomBossReinforcement doGlobalSummonReinforcement(String filename) {
CustomBossReinforcement customBossReinforcement = new CustomBossReinforcement(SummonType.GLOBAL, filename);
CustomBossesConfigFields customBossesConfigFields = CustomBossesConfig.getCustomBoss(customBossReinforcement.bossFileName);
if (customBossesConfigFields == null) {
new WarningMessage("Reinforcement mob " + customBossReinforcement.bossFileName + " is not valid!");
return null;
}
customBossReinforcement.entityType = customBossesConfigFields.getEntityType();
customBossReinforcements.add(customBossReinforcement);
return customBossReinforcement;
}
use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class PhotonRay method doRaytraceLaser.
private void doRaytraceLaser(Vector laserVector, Location source, boolean warningPhase, EliteEntity eliteEntity) {
Location cloneLocation = source.clone().add(new Vector(0, 1, 0));
for (int i = 0; i < range * 2; i++) {
if (!cloneLocation.clone().add(laserVector).getBlock().isPassable()) {
Vector tentativeDistance = cloneLocation.clone().add(laserVector).getBlock().getLocation().add(new Vector(0.5, 0.5, 0.5)).subtract(cloneLocation.clone()).toVector();
double x = laserVector.getX(), y = laserVector.getY(), z = laserVector.getZ();
double xAbs = Math.abs(tentativeDistance.getX()), yAbs = Math.abs(tentativeDistance.getY()), zAbs = Math.abs(tentativeDistance.getZ());
if (xAbs > yAbs && xAbs > zAbs)
x *= -1;
else if (yAbs > xAbs && yAbs > zAbs)
y *= -1;
else if (zAbs > yAbs && zAbs > xAbs)
z *= -1;
else
new WarningMessage("MagmaGuy is bad at math!");
laserVector.setX(x);
laserVector.setY(y);
laserVector.setZ(z);
}
if (warningPhase)
doWarningParticle(cloneLocation.add(laserVector));
else
doDamageParticles(eliteEntity, cloneLocation.add(laserVector));
}
}
use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class SummonTheReturned method doSummon.
private void doSummon(EliteEntity eliteEntity) {
for (int i = 0; i < 10; i++) {
Location spawnLocation = eliteEntity.getLivingEntity().getLocation();
CustomBossEntity.createCustomBossEntity("the_returned.yml").spawn(spawnLocation, eliteEntity.getLevel(), false);
double x = ThreadLocalRandom.current().nextDouble() - 0.5;
double z = ThreadLocalRandom.current().nextDouble() - 0.5;
try {
eliteEntity.getLivingEntity().setVelocity(new Vector(x, 0.5, z));
} catch (Exception ex) {
new WarningMessage("Attempted to complete Summon the Returned power but a reinforcement mob wasn't detected! Did the boss move to an area that prevents spawning?");
}
}
}
use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class CustomBossMount method generateMount.
public static CustomBossEntity generateMount(CustomBossEntity customBossEntity) {
if (customBossEntity.customBossesConfigFields.getMountedEntity() == null)
return null;
try {
EntityType entityType = EntityType.valueOf(customBossEntity.customBossesConfigFields.getMountedEntity());
LivingEntity livingEntity = (LivingEntity) customBossEntity.getLivingEntity().getWorld().spawnEntity(customBossEntity.getLivingEntity().getLocation(), entityType);
PreventMountExploit.bypass = true;
livingEntity.addPassenger(customBossEntity.getLivingEntity());
livingEntity.setRemoveWhenFarAway(false);
customBossEntity.livingEntityMount = livingEntity;
} catch (Exception ex) {
// This runs when it's not an API entity
CustomBossesConfigFields customBossesConfigFields = CustomBossesConfig.getCustomBoss(customBossEntity.customBossesConfigFields.getMountedEntity());
if (customBossesConfigFields != null) {
CustomBossEntity mountEntity = CustomBossEntity.createCustomBossEntity(customBossEntity.customBossesConfigFields.getMountedEntity());
if (mountEntity == null) {
new WarningMessage("Mount for boss " + customBossEntity.getCustomBossesConfigFields().getFilename() + " is not valid!");
return null;
}
mountEntity.setSpawnLocation(customBossEntity.getLivingEntity().getLocation());
mountEntity.setBypassesProtections(customBossEntity.getBypassesProtections());
mountEntity.setPersistent(false);
mountEntity.setMount(true);
mountEntity.spawn(false);
new BukkitRunnable() {
@Override
public void run() {
if (!mountEntity.isValid())
return;
PreventMountExploit.bypass = true;
mountEntity.getLivingEntity().addPassenger(customBossEntity.getLivingEntity());
customBossEntity.customBossMount = mountEntity;
}
}.runTaskLater(MetadataHandler.PLUGIN, 5);
return mountEntity;
}
new WarningMessage("Attempted to make Custom Boss " + customBossEntity.customBossesConfigFields.getFilename() + " mount invalid" + " entity or boss " + customBossEntity.customBossesConfigFields.getMountedEntity() + " . Fix this in the configuration file.");
}
return null;
}
Aggregations