Search in sources :

Example 6 with FixedMetadataValue

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

the class DoubleHealth method applyPowers.

@Override
public void applyPowers(Entity entity) {
    if (!(entity instanceof IronGolem)) {
        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) IronGolem(org.bukkit.entity.IronGolem)

Example 7 with FixedMetadataValue

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

the class LevelHandler method LevelHandler.

public static void LevelHandler(Entity entity, Entity deletedEntity, Plugin plugin) {
    //No previous metadata, assume it's the first level
    if (!entity.hasMetadata(MetadataHandler.ELITE_MOB_MD) && !deletedEntity.hasMetadata(MetadataHandler.ELITE_MOB_MD)) {
        entity.setMetadata(MetadataHandler.ELITE_MOB_MD, new FixedMetadataValue(plugin, 2));
    } else if (entity.hasMetadata(MetadataHandler.ELITE_MOB_MD) && !deletedEntity.hasMetadata(MetadataHandler.ELITE_MOB_MD)) {
        int finalMetadata = entity.getMetadata(MetadataHandler.ELITE_MOB_MD).get(0).asInt() + 1;
        entity.setMetadata(MetadataHandler.ELITE_MOB_MD, new FixedMetadataValue(plugin, finalMetadata));
    } else if (!entity.hasMetadata(MetadataHandler.ELITE_MOB_MD) && deletedEntity.hasMetadata(MetadataHandler.ELITE_MOB_MD)) {
        int finalMetadata = deletedEntity.getMetadata(MetadataHandler.ELITE_MOB_MD).get(0).asInt() + 1;
        entity.setMetadata(MetadataHandler.ELITE_MOB_MD, new FixedMetadataValue(plugin, finalMetadata));
    } else if (entity.hasMetadata(MetadataHandler.ELITE_MOB_MD) && deletedEntity.hasMetadata(MetadataHandler.ELITE_MOB_MD)) {
        int finalMetadata = entity.getMetadata(MetadataHandler.ELITE_MOB_MD).get(0).asInt() + deletedEntity.getMetadata(MetadataHandler.ELITE_MOB_MD).get(0).asInt();
        entity.setMetadata(MetadataHandler.ELITE_MOB_MD, new FixedMetadataValue(plugin, finalMetadata));
    } else {
        getLogger().info("EliteMobs - Invalid metadata state - Contact the dev!");
    }
}
Also used : FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue)

Example 8 with FixedMetadataValue

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

the class ZombieFriends method onHit.

@EventHandler
public void onHit(EntityDamageEvent event) {
    if (event.getEntity().hasMetadata(powerMetadata) && event.getEntity() instanceof Zombie && !event.getEntity().hasMetadata(MetadataHandler.ZOMBIE_FRIENDS_ACTIVATED) && random.nextDouble() < 0.5) {
        Entity entity = event.getEntity();
        entity.setMetadata(MetadataHandler.ZOMBIE_FRIENDS_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;
        }
        Zombie friend1 = (Zombie) entity.getWorld().spawnEntity(entity.getLocation(), EntityType.ZOMBIE);
        Zombie friend2 = (Zombie) entity.getWorld().spawnEntity(entity.getLocation(), EntityType.ZOMBIE);
        friend1.setMetadata(MetadataHandler.ELITE_MOB_MD, new FixedMetadataValue(plugin, assistMobLevel));
        friend2.setMetadata(MetadataHandler.ELITE_MOB_MD, new FixedMetadataValue(plugin, assistMobLevel));
        friend1.setMetadata(MetadataHandler.FORBIDDEN_MD, new FixedMetadataValue(plugin, true));
        friend2.setMetadata(MetadataHandler.FORBIDDEN_MD, new FixedMetadataValue(plugin, true));
        friend1.setMetadata(MetadataHandler.CUSTOM_POWERS_MD, new FixedMetadataValue(plugin, true));
        friend2.setMetadata(MetadataHandler.CUSTOM_POWERS_MD, new FixedMetadataValue(plugin, true));
        friend1.setCustomName(chatColorConverter(configuration.getString("ZombieFriends.Friend 1")));
        friend2.setCustomName(chatColorConverter(configuration.getString("ZombieFriends.Friend 2")));
        friend1.setCustomNameVisible(true);
        friend2.setCustomNameVisible(true);
        processID = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {

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

Example 9 with FixedMetadataValue

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

the class ZombieNecronomicon method necronomiconVisualEffect.

private void necronomiconVisualEffect(Zombie zombie) {
    summoningEffectOn = true;
    nameScroller(zombie);
    if (!ConfigValues.defaultConfig.getBoolean("Turn on visual effects that indicate an attack is about to happen")) {
        return;
    }
    new BukkitRunnable() {

        int counter = 0;

        HashMap<Integer, List<Item>> fourTrack = new HashMap();

        @Override
        public void run() {
            if (!zombie.isValid() || zombie.hasAI()) {
                for (List<Item> itemList : fourTrack.values()) {
                    for (Item item : itemList) {
                        item.removeMetadata(MetadataHandler.MAJOR_VISUAL_EFFECT_MD, plugin);
                        item.remove();
                    }
                }
                if (zombie.isValid()) {
                    zombie.setCustomName(NameHandler.customAggressiveName(zombie));
                }
                summoningEffectOn = false;
                cancel();
                return;
            }
            if (counter == 0) {
                //establish 4tracks
                for (int i = 0; i < 8; i++) {
                    List<Item> itemList = new ArrayList<>();
                    for (int j = 0; j < 4; j++) {
                        ItemStack itemStack = new ItemStack(Material.WRITTEN_BOOK, 1);
                        Item item = zombie.getWorld().dropItem(zombie.getLocation(), itemStack);
                        item.setGravity(false);
                        item.setPickupDelay(Integer.MAX_VALUE);
                        item.setMetadata(MetadataHandler.MAJOR_VISUAL_EFFECT_MD, new FixedMetadataValue(plugin, true));
                        itemList.add(item);
                    }
                    fourTrack.put(i, itemList);
                }
            } else {
                itemMover(fourTrack, zombie, counter);
            }
            counter++;
        }
    }.runTaskTimer(plugin, 5, 5);
}
Also used : BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) ItemStack(org.bukkit.inventory.ItemStack)

Example 10 with FixedMetadataValue

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

the class ZombieNecronomicon 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)

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