Search in sources :

Example 11 with WarningMessage

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();
    }
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration) WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage)

Example 12 with WarningMessage

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);
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) Method(java.lang.reflect.Method)

Example 13 with WarningMessage

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;
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) Vector(org.bukkit.util.Vector)

Example 14 with WarningMessage

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!");
    }
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) PotionEffect(org.bukkit.potion.PotionEffect) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) Vector(org.bukkit.util.Vector)

Example 15 with WarningMessage

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);
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) Item(org.bukkit.entity.Item) HashMap(java.util.HashMap) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) MobCombatSettingsConfig(com.magmaguy.elitemobs.config.MobCombatSettingsConfig) MajorPower(com.magmaguy.elitemobs.powers.meta.MajorPower) ArrayList(java.util.ArrayList) EventHandler(org.bukkit.event.EventHandler) Location(org.bukkit.Location) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) MetadataHandler(com.magmaguy.elitemobs.MetadataHandler) ChatColorConverter.convert(com.magmaguy.elitemobs.ChatColorConverter.convert) GenericRotationMatrixMath(com.magmaguy.elitemobs.powerstances.GenericRotationMatrixMath) EliteMobDamagedByPlayerEvent(com.magmaguy.elitemobs.api.EliteMobDamagedByPlayerEvent) Material(org.bukkit.Material) Listener(org.bukkit.event.Listener) Entity(org.bukkit.entity.Entity) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) VisualItemInitializer(com.magmaguy.elitemobs.powerstances.VisualItemInitializer) EntityTracker(com.magmaguy.elitemobs.entitytracker.EntityTracker) LivingEntity(org.bukkit.entity.LivingEntity) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) ItemStack(org.bukkit.inventory.ItemStack) Vector(org.bukkit.util.Vector) List(java.util.List) PowersConfig(com.magmaguy.elitemobs.config.powers.PowersConfig) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) ArrayList(java.util.ArrayList) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) Vector(org.bukkit.util.Vector)

Aggregations

WarningMessage (com.magmaguy.elitemobs.utils.WarningMessage)76 InfoMessage (com.magmaguy.elitemobs.utils.InfoMessage)11 Vector (org.bukkit.util.Vector)11 Item (org.bukkit.entity.Item)10 File (java.io.File)9 CustomBossEntity (com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)8 FlagConflictException (com.sk89q.worldguard.protection.flags.registry.FlagConflictException)7 RegionManager (com.sk89q.worldguard.protection.managers.RegionManager)6 RegionContainer (com.sk89q.worldguard.protection.regions.RegionContainer)6 ArrayList (java.util.ArrayList)6 ZipFile (com.magmaguy.elitemobs.utils.ZipFile)5 GlobalProtectedRegion (com.sk89q.worldguard.protection.regions.GlobalProtectedRegion)5 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)5 Location (org.bukkit.Location)5 ItemStack (org.bukkit.inventory.ItemStack)5 CustomBossesConfigFields (com.magmaguy.elitemobs.config.custombosses.CustomBossesConfigFields)3 Minidungeon (com.magmaguy.elitemobs.dungeons.Minidungeon)3 IOException (java.io.IOException)3 Material (org.bukkit.Material)3 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)3