Search in sources :

Example 11 with FixedMetadataValue

use of org.bukkit.metadata.FixedMetadataValue in project EliteMobs by MagmaGuy.

the class ZombieParents method applyPowers.

@Override
public void applyPowers(Entity entity) {
    entity.setMetadata(powerMetadata, new FixedMetadataValue(plugin, true));
    MajorPowerPowerStance majorPowerStanceMath = new MajorPowerPowerStance();
    majorPowerStanceMath.itemEffect(entity);
}
Also used : FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) MajorPowerPowerStance(com.magmaguy.elitemobs.powerstances.MajorPowerPowerStance)

Example 12 with FixedMetadataValue

use of org.bukkit.metadata.FixedMetadataValue in project EliteMobs by MagmaGuy.

the class ZombieParents method onHit.

@EventHandler
public void onHit(EntityDamageEvent event) {
    if (event.getEntity().hasMetadata(powerMetadata) && event.getEntity() instanceof Zombie && !event.getEntity().hasMetadata(MetadataHandler.ZOMBIE_PARENTS_ACTIVATED) && random.nextDouble() < 0.5) {
        Entity entity = event.getEntity();
        entity.setMetadata(MetadataHandler.ZOMBIE_PARENTS_ACTIVATED, new FixedMetadataValue(plugin, true));
        int assistMobLevel = (int) Math.floor(entity.getMetadata(MetadataHandler.ELITE_MOB_MD).get(0).asInt() / 4);
        if (assistMobLevel < 1) {
            assistMobLevel = 1;
        }
        Skeleton zombieMom = (Skeleton) entity.getWorld().spawnEntity(entity.getLocation(), EntityType.SKELETON);
        Skeleton zombieDad = (Skeleton) entity.getWorld().spawnEntity(entity.getLocation(), EntityType.SKELETON);
        zombieDad.setCustomName(chatColorConverter(configuration.getString("ZombieParents.Dad Name")));
        zombieMom.setCustomName(chatColorConverter(configuration.getString("ZombieParents.Mom Name")));
        zombieDad.setCustomNameVisible(true);
        zombieMom.setCustomNameVisible(true);
        zombieDad.setMetadata(MetadataHandler.ELITE_MOB_MD, new FixedMetadataValue(plugin, assistMobLevel));
        zombieMom.setMetadata(MetadataHandler.ELITE_MOB_MD, new FixedMetadataValue(plugin, assistMobLevel));
        zombieDad.setMetadata(MetadataHandler.FORBIDDEN_MD, new FixedMetadataValue(plugin, true));
        zombieMom.setMetadata(MetadataHandler.FORBIDDEN_MD, new FixedMetadataValue(plugin, true));
        zombieDad.setMetadata(MetadataHandler.CUSTOM_POWERS_MD, new FixedMetadataValue(plugin, true));
        zombieMom.setMetadata(MetadataHandler.CUSTOM_POWERS_MD, new FixedMetadataValue(plugin, true));
        zombieDad.setMetadata(MetadataHandler.CUSTOM_NAME, new FixedMetadataValue(plugin, true));
        zombieMom.setMetadata(MetadataHandler.CUSTOM_NAME, new FixedMetadataValue(plugin, true));
        processID = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {

            @Override
            public void run() {
                if (!entity.isValid()) {
                    if (zombieDad.isValid()) {
                        nameClearer(zombieDad);
                        zombieDad.setCustomName(chatColorConverter(configuration.getStringList("ZombieParents.DeathMessage").get(random.nextInt(configuration.getStringList("ZombieParents.DeathMessage").size()))));
                    }
                    if (zombieMom.isValid()) {
                        nameClearer(zombieMom);
                        zombieMom.setCustomName(chatColorConverter(configuration.getStringList("ZombieParents.DeathMessage").get(random.nextInt(configuration.getStringList("ZombieParents.DeathMessage").size()))));
                    }
                    Bukkit.getScheduler().cancelTask(processID);
                    return;
                } else {
                    if (random.nextDouble() < 0.5) {
                        nameClearer(entity);
                        entity.setCustomName(chatColorConverter(configuration.getStringList("ZombieParents.ZombieDialog").get(random.nextInt(configuration.getStringList("ZombieParents.ZombieDialog").size()))));
                    }
                    if (random.nextDouble() < 0.5 && zombieDad.isValid()) {
                        nameClearer(zombieDad);
                        zombieDad.setCustomName(chatColorConverter(configuration.getStringList("ZombieParents.ZombieDadDialog").get(random.nextInt(configuration.getStringList("ZombieParents.ZombieDadDialog").size()))));
                    }
                    if (random.nextDouble() < 0.5 && zombieMom.isValid()) {
                        nameClearer(zombieMom);
                        zombieMom.setCustomName(chatColorConverter(configuration.getStringList("ZombieParents.ZombieMomDialog").get(random.nextInt(configuration.getStringList("ZombieParents.ZombieMomDialog").size()))));
                    }
                }
            }
        }, 20, 20 * 8);
    }
}
Also used : Entity(org.bukkit.entity.Entity) Zombie(org.bukkit.entity.Zombie) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) Skeleton(org.bukkit.entity.Skeleton) EventHandler(org.bukkit.event.EventHandler)

Example 13 with FixedMetadataValue

use of org.bukkit.metadata.FixedMetadataValue in project EliteMobs by MagmaGuy.

the class AttackArrow method attackArrow.

@EventHandler
public void attackArrow(EntityTargetEvent event) {
    if (event.getEntity().hasMetadata(powerMetadata) && !event.getEntity().hasMetadata(MetadataHandler.SHOOTING_ARROWS)) {
        Entity targetter = event.getEntity();
        Entity targetted = event.getTarget();
        if (targetted instanceof Player) {
            targetter.setMetadata(MetadataHandler.SHOOTING_ARROWS, new FixedMetadataValue(plugin, true));
            new BukkitRunnable() {

                @Override
                public void run() {
                    if (!targetted.isValid() || !targetter.isValid() || targetter.getWorld() != targetted.getWorld() || targetted.getLocation().distance(targetter.getLocation()) > 20) {
                        targetter.removeMetadata(MetadataHandler.SHOOTING_ARROWS, plugin);
                        cancel();
                        return;
                    }
                    Entity repeatingArrow = targetter.getWorld().spawnEntity(targetter.getLocation().add(0, 3, 0), EntityType.ARROW);
                    Vector targetterToTargetted = targetted.getLocation().toVector().subtract(repeatingArrow.getLocation().toVector());
                    double distanceNerfRepeating = (targetted.getLocation().distance(targetter.getLocation())) / 100;
                    repeatingArrow.setVelocity(targetterToTargetted.multiply(0.5 - distanceNerfRepeating));
                }
            }.runTaskTimer(plugin, 0, 100);
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) Player(org.bukkit.entity.Player) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Vector(org.bukkit.util.Vector) EventHandler(org.bukkit.event.EventHandler)

Example 14 with FixedMetadataValue

use of org.bukkit.metadata.FixedMetadataValue in project EliteMobs by MagmaGuy.

the class AttackBlinding method applyPowers.

@Override
public void applyPowers(Entity entity) {
    entity.setMetadata(powerMetadata, new FixedMetadataValue(plugin, true));
    MinorPowerPowerStance minorPowerPowerStance = new MinorPowerPowerStance();
    minorPowerPowerStance.itemEffect(entity);
}
Also used : FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) MinorPowerPowerStance(com.magmaguy.elitemobs.powerstances.MinorPowerPowerStance)

Example 15 with FixedMetadataValue

use of org.bukkit.metadata.FixedMetadataValue in project EliteMobs by MagmaGuy.

the class AttackPoison method applyPowers.

@Override
public void applyPowers(Entity entity) {
    entity.setMetadata(powerMetadata, new FixedMetadataValue(plugin, true));
    MinorPowerPowerStance minorPowerPowerStance = new MinorPowerPowerStance();
    minorPowerPowerStance.itemEffect(entity);
}
Also used : FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) MinorPowerPowerStance(com.magmaguy.elitemobs.powerstances.MinorPowerPowerStance)

Aggregations

FixedMetadataValue (org.bukkit.metadata.FixedMetadataValue)52 MinorPowerPowerStance (com.magmaguy.elitemobs.powerstances.MinorPowerPowerStance)22 Entity (org.bukkit.entity.Entity)9 EventHandler (org.bukkit.event.EventHandler)8 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)7 LivingEntity (org.bukkit.entity.LivingEntity)6 Player (org.bukkit.entity.Player)5 ItemStack (org.bukkit.inventory.ItemStack)5 MajorPowerPowerStance (com.magmaguy.elitemobs.powerstances.MajorPowerPowerStance)4 Item (org.bukkit.entity.Item)4 Zombie (org.bukkit.entity.Zombie)4 Vector (org.bukkit.util.Vector)4 IronGolem (org.bukkit.entity.IronGolem)3 PotionEffect (org.bukkit.potion.PotionEffect)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Random (java.util.Random)2 Location (org.bukkit.Location)2 World (org.bukkit.World)2 Block (org.bukkit.block.Block)2