use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class CustomConfig method initialize.
/**
* Called when a user-made file is detected.
*/
private void initialize(File file) {
// Load file configuration from file
try {
FileConfiguration fileConfiguration = YamlConfiguration.loadConfiguration(file);
// Instantiate the correct CustomConfigFields instance
Constructor<?> constructor = customConfigFields.getConstructor(String.class, boolean.class);
CustomConfigFields instancedCustomConfigFields = (CustomConfigFields) constructor.newInstance(file.getName(), true);
instancedCustomConfigFields.setFileConfiguration(fileConfiguration);
instancedCustomConfigFields.setFile(file);
// Parse actual fields and load into RAM to be used
instancedCustomConfigFields.processConfigFields();
// if (instancedCustomConfigFields.isEnabled)
// Store for use by the plugin
addCustomConfigFields(file.getName(), instancedCustomConfigFields);
} catch (Exception ex) {
new WarningMessage("Bad constructor for file " + file.getName());
ex.printStackTrace();
}
}
use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class CustomConfig method fileInitializer.
private void fileInitializer(File file) {
boolean isPremade = false;
for (Object object : customConfigFieldsArrayList) {
try {
Method getFilename = CustomConfigFields.class.getDeclaredMethod("getFilename");
if (file.getName().equalsIgnoreCase((String) getFilename.invoke(object))) {
customConfigFieldsArrayList.remove(object);
initialize((CustomConfigFields) object);
isPremade = true;
break;
}
} catch (Exception ex) {
new WarningMessage("Failed to read plugin files for " + folderName + " ! This is very bad, warn the developer!");
isPremade = true;
ex.printStackTrace();
}
}
if (!isPremade)
initialize(file);
}
use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class CustomConfigFields method processVector.
protected Vector processVector(String path, Vector value, Vector pluginDefault, boolean forceWriteDefault) {
if (!configHas(path)) {
if (forceWriteDefault || !Objects.equals(value, pluginDefault))
if (pluginDefault != null) {
String vectorString = value.getX() + "," + value.getY() + "," + value.getZ();
fileConfiguration.addDefault(path, vectorString);
}
return value;
}
try {
String string = fileConfiguration.getString(path);
if (string == null)
return null;
String[] strings = string.split(",");
if (strings.length < 3) {
new WarningMessage("File " + filename + " has an incorrect entry for " + path);
return null;
}
return new Vector(Double.parseDouble(strings[0]), Double.parseDouble(strings[1]), Double.parseDouble(strings[2]));
} catch (Exception ex) {
new WarningMessage("File " + filename + " has an incorrect entry for " + path);
new WarningMessage("Entry: " + value);
}
return null;
}
use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class EnderDragonEndermiteBombardment method taskBehavior.
@Override
public void taskBehavior(EliteEntity eliteEntity) {
try {
Vector direction = eliteEntity.getLivingEntity().getLocation().getDirection();
float rotation = (float) (Math.atan2(direction.getX(), direction.getZ()) * 180 / Math.PI);
Vector direction1 = new Vector(1, -4, 0);
Vector direction2 = new Vector(-1, -4, 0);
direction1 = direction1.rotateAroundY(rotation);
direction2 = direction2.rotateAroundY(rotation);
CustomBossEntity customBossEntity1 = CustomBossEntity.createCustomBossEntity("binder_of_worlds_phase_1_endermite_reinforcement.yml");
customBossEntity1.spawn(eliteEntity.getLivingEntity().getLocation().clone().add(direction1), false);
customBossEntity1.getLivingEntity().addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 20 * 5, 0));
eliteEntity.addReinforcement(customBossEntity1);
CustomBossEntity customBossEntity2 = CustomBossEntity.createCustomBossEntity("binder_of_worlds_phase_1_endermite_reinforcement.yml");
customBossEntity2.spawn(eliteEntity.getLivingEntity().getLocation().clone().add(direction2), false);
customBossEntity2.getLivingEntity().addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 20 * 5, 0));
eliteEntity.addReinforcement(customBossEntity2);
} catch (Exception ex) {
new WarningMessage("Failed to spawn binder of world's reinforcement endermite!");
}
}
use of com.magmaguy.elitemobs.utils.WarningMessage in project EliteMobs by MagmaGuy.
the class ZombieNecronomicon method spawnReinforcements.
private void spawnReinforcements(EliteEntity eliteEntity, LivingEntity targetted, ZombieNecronomicon zombieNecronomicon) {
LivingEntity targetter = eliteEntity.getLivingEntity();
new BukkitRunnable() {
final ArrayList<Entity> entityList = new ArrayList<>();
@Override
public void run() {
if (!eliteEntity.isValid() || !targetted.isValid() || !targetter.isValid() || targetted.getWorld() != targetter.getWorld() || targetted.getLocation().distance(targetter.getLocation()) > 30) {
for (Entity entity : entityList) if (entity.isValid())
entity.remove();
if (eliteEntity.isValid())
targetter.setAI(true);
cancel();
return;
}
int randomizedNumber = ThreadLocalRandom.current().nextInt(5) + 1;
entityList.removeIf(currentEntity -> !currentEntity.isValid());
if (entityList.size() < 11) {
targetter.setAI(false);
if (!zombieNecronomicon.isFiring())
necronomiconVisualEffect(eliteEntity, zombieNecronomicon);
if (randomizedNumber < 5) {
CustomBossEntity customBossEntity = CustomBossEntity.createCustomBossEntity("necronomicon_zombie.yml");
if (customBossEntity == null) {
new WarningMessage("necronomicon_zombie.yml is not valid!");
return;
}
customBossEntity.spawn(targetter.getLocation(), eliteEntity.getLevel(), false);
if (!customBossEntity.getLivingEntity().isValid()) {
targetter.setAI(true);
cancel();
targetter.setAI(true);
cancel();
return;
}
customBossEntity.getLivingEntity().setVelocity(new Vector((ThreadLocalRandom.current().nextDouble() - 0.5) / 30, 0.5, (ThreadLocalRandom.current().nextDouble() - 0.5) / 30));
eliteEntity.addReinforcement(customBossEntity);
entityList.add(customBossEntity.getLivingEntity());
} else {
CustomBossEntity customBossEntity = CustomBossEntity.createCustomBossEntity("necronomicon_skeleton.yml");
if (customBossEntity == null) {
new WarningMessage("necronomicon_skeleton.yml is not valid!");
targetter.setAI(true);
cancel();
return;
}
customBossEntity.spawn(targetter.getLocation(), eliteEntity.getLevel(), false);
if (!customBossEntity.getLivingEntity().isValid()) {
targetter.setAI(true);
cancel();
return;
}
customBossEntity.getLivingEntity().setVelocity(new Vector((ThreadLocalRandom.current().nextDouble() - 0.5) / 30, 0.5, (ThreadLocalRandom.current().nextDouble() - 0.5) / 30));
eliteEntity.addReinforcement(customBossEntity);
entityList.add(customBossEntity.getLivingEntity());
}
} else
targetter.setAI(true);
}
}.runTaskTimer(MetadataHandler.PLUGIN, 20 * 3L, 20 * 3L);
}
Aggregations