Search in sources :

Example 41 with FixedMetadataValue

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

the class AttackWeb method webEffectApplier.

private void webEffectApplier(int counter, Entity damagee, Block block) {
    if (counter == 0) {
        damagee.setMetadata("WebCooldown", new FixedMetadataValue(plugin, true));
        block.setType(Material.WEB);
        block.setMetadata("TemporaryBlock", new FixedMetadataValue(plugin, true));
    }
    if (counter == 20 * 4) {
        block.setType(Material.AIR);
        block.removeMetadata("TemporaryBlock", plugin);
    }
    if (counter == 20 * 7) {
        damagee.removeMetadata("WebCooldown", plugin);
        Bukkit.getScheduler().cancelTask(processID);
    }
}
Also used : FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue)

Example 42 with FixedMetadataValue

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

the class NaturalMobMetadataAssigner method onSpawn.

@EventHandler
public void onSpawn(CreatureSpawnEvent event) {
    if (!ConfigValues.defaultConfig.getBoolean("Natural aggressive EliteMob spawning") || !ConfigValues.defaultConfig.getBoolean("Allow aggressive EliteMobs") || !ConfigValues.defaultConfig.getBoolean("Valid worlds." + event.getEntity().getWorld().getName().toString())) {
        return;
    }
    if (event.getSpawnReason() == NATURAL || event.getSpawnReason() == CUSTOM) {
        Entity entity = event.getEntity();
        if (ValidAgressiveMobFilter.ValidAgressiveMobFilter(entity)) {
            Random random = new Random();
            entity.setMetadata(MetadataHandler.NATURAL_MOB_MD, new FixedMetadataValue(plugin, true));
            //20% chance of turning a mob into a EliteMob unless special gear is equipped
            int huntingGearChanceAdder = 0;
            for (Entity surroundingEntity : entity.getNearbyEntities(range, range, range)) {
                if (surroundingEntity instanceof Player) {
                    Player player = (Player) surroundingEntity;
                    ItemStack helmet = player.getInventory().getHelmet();
                    ItemStack chestplate = player.getInventory().getChestplate();
                    ItemStack leggings = player.getInventory().getLeggings();
                    ItemStack boots = player.getInventory().getBoots();
                    ItemStack heldItem = player.getInventory().getItemInMainHand();
                    for (ItemStack itemStack : EliteDropsHandler.lootList) {
                        if (helmet != null && itemStack.getItemMeta().equals(helmet.getItemMeta()) && helmet.getItemMeta().getDisplayName().equalsIgnoreCase(chatColorConverter("&4elite mob hunting helmet"))) {
                            huntingGearChanceAdder++;
                        } else if (chestplate != null && chestplate.getItemMeta().equals(itemStack.getItemMeta()) && chestplate.getItemMeta().getDisplayName().equalsIgnoreCase(chatColorConverter("&4elite mob hunting chestplate"))) {
                            huntingGearChanceAdder++;
                        } else if (leggings != null && leggings.getItemMeta().equals(itemStack.getItemMeta()) && leggings.getItemMeta().getDisplayName().equalsIgnoreCase(chatColorConverter("&4elite mob hunting leggings"))) {
                            huntingGearChanceAdder++;
                        } else if (boots != null && boots.getItemMeta().equals(itemStack.getItemMeta()) && boots.getItemMeta().getDisplayName().equalsIgnoreCase(chatColorConverter("&4elite mob hunting boots"))) {
                            huntingGearChanceAdder++;
                        } else if (heldItem != null && heldItem.getType() != Material.AIR && heldItem.getItemMeta().equals(itemStack.getItemMeta()) && heldItem.getItemMeta().getDisplayName().equalsIgnoreCase(chatColorConverter("&4elite mob hunting bow"))) {
                            huntingGearChanceAdder++;
                        }
                    }
                }
            }
            if (random.nextDouble() < ConfigValues.defaultConfig.getDouble("Percentage (%) of aggressive mobs that get converted to EliteMobs when they spawn") / 100 + huntingGearChanceAdder * 10) {
                NaturalMobSpawner naturalMobSpawner = new NaturalMobSpawner(plugin);
                naturalMobSpawner.naturalMobProcessor(entity);
            }
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) Player(org.bukkit.entity.Player) Random(java.util.Random) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) ItemStack(org.bukkit.inventory.ItemStack) EventHandler(org.bukkit.event.EventHandler)

Example 43 with FixedMetadataValue

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

the class NaturalMobSpawner method naturalMobProcessor.

public void naturalMobProcessor(Entity entity) {
    Random random = new Random();
    List<Entity> scanEntity = entity.getNearbyEntities(range, range, range);
    int amountOfPlayersTogether = 0;
    for (Entity scannedEntity : scanEntity) {
        amountOfPlayersTogether++;
        if (//vanishnopacket support
        scannedEntity instanceof Player) {
            Player player = (Player) scannedEntity;
            int armorRating = 0;
            armorRating = armorRatingHandler(player, armorRating);
            int potionEffectRating = player.getActivePotionEffects().size();
            int EliteMobRating = 0;
            EliteMobRating = EliteMobRating(player, EliteMobRating, range);
            int threathLevel = 0;
            threathLevel = threatLevelCalculator(armorRating, potionEffectRating, EliteMobRating);
            int EliteMobLevel = levelCalculator(threathLevel);
            if (threathLevel == 0) {
                return;
            }
            //Just set up the metadata, scanner will pick it up and apply the correct stats
            if (amountOfPlayersTogether == 1) {
                entity.setMetadata(MetadataHandler.ELITE_MOB_MD, new FixedMetadataValue(plugin, EliteMobLevel));
            } else if (amountOfPlayersTogether > 1 && random.nextDouble() < 20) {
                entity.setMetadata(MetadataHandler.ELITE_MOB_MD, new FixedMetadataValue(plugin, EliteMobLevel));
            }
        }
    }
}
Also used : Entity(org.bukkit.entity.Entity) Player(org.bukkit.entity.Player) Random(java.util.Random) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue)

Example 44 with FixedMetadataValue

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

the class MajorPowerPowerStance method itemEffect.

public void itemEffect(Entity entity) {
    if (ConfigValues.defaultConfig.getBoolean("Turn on visual effects for natural or plugin-spawned EliteMobs")) {
        if (ConfigValues.defaultConfig.getBoolean("Turn off visual effects for non-natural or non-plugin-spawned EliteMobs") && !entity.hasMetadata(MetadataHandler.NATURAL_MOB_MD)) {
            return;
        }
        if (entity.hasMetadata(MetadataHandler.MAJOR_VISUAL_EFFECT_MD)) {
            return;
        }
        entity.setMetadata(MetadataHandler.MAJOR_VISUAL_EFFECT_MD, new FixedMetadataValue(plugin, 0));
        //First integer counts the visual effects it's in, hashmap is from MajorPowerStance's trackHashMap
        HashMap<Integer, HashMap<Integer, List<Item>>> powerItemLocationTracker = new HashMap<>();
        new BukkitRunnable() {

            int counter = 0;

            int zombieFriendsCounter = 0;

            int zombieNecronomiconCounter = 0;

            int zombieTeamRocketCounter = 0;

            int zombieParentsCounter = 0;

            @Override
            public void run() {
                //                    int effectQuantity = 0;
                int effectIteration = 0;
                if (counter >= 10) {
                    counter = 0;
                }
                if (entity.hasMetadata(MetadataHandler.ZOMBIE_FRIENDS_MD)) {
                    ItemStack itemStack = new ItemStack(Material.SKULL_ITEM, 1, (short) 2);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, zombieFriendsCounter);
                    effectIteration++;
                    zombieFriendsCounter++;
                    if (zombieFriendsCounter >= MajorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        zombieFriendsCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.ZOMBIE_NECRONOMICON_MD)) {
                    ItemStack itemStack = new ItemStack(Material.WRITTEN_BOOK, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, zombieNecronomiconCounter);
                    effectIteration++;
                    zombieNecronomiconCounter++;
                    if (zombieNecronomiconCounter >= MajorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        zombieNecronomiconCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.ZOMBIE_TEAM_ROCKET_MD)) {
                    ItemStack itemStack = new ItemStack(Material.FIREWORK, 1);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, zombieTeamRocketCounter);
                    effectIteration++;
                    zombieTeamRocketCounter++;
                    if (zombieTeamRocketCounter >= MajorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        zombieTeamRocketCounter = 0;
                    }
                }
                if (entity.hasMetadata(MetadataHandler.ZOMBIE_PARENTS_MD)) {
                    ItemStack itemStack = new ItemStack(Material.MONSTER_EGG, 1, (short) 0, (byte) 54);
                    itemProcessor(powerItemLocationTracker, itemStack, effectIteration, entity, zombieParentsCounter);
                    effectIteration++;
                    zombieParentsCounter++;
                    if (zombieParentsCounter >= MajorPowerStanceMath.NUMBER_OF_POINTS_PER_FULL_ROTATION) {
                        zombieParentsCounter = 0;
                    }
                }
                if (!entity.isValid() || entity.isDead()) {
                    for (int i = 0; i < powerItemLocationTracker.size(); i++) {
                        for (int j = 0; j < trackAmount; j++) {
                            for (int h = 0; h < itemsPerTrack; h++) {
                                powerItemLocationTracker.get(i).get(j).get(h).remove();
                                powerItemLocationTracker.get(i).get(j).get(h).removeMetadata(MetadataHandler.MAJOR_VISUAL_EFFECT_MD, plugin);
                            }
                        }
                    }
                    entity.removeMetadata(MetadataHandler.MAJOR_VISUAL_EFFECT_MD, plugin);
                    cancel();
                    return;
                }
                counter++;
            }
        }.runTaskTimer(plugin, 0, 5);
    }
}
Also used : Item(org.bukkit.entity.Item) HashMap(java.util.HashMap) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) ItemStack(org.bukkit.inventory.ItemStack)

Example 45 with FixedMetadataValue

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

the class MajorPowerPowerStance method itemInitializer.

private Item itemInitializer(ItemStack itemStack, Location location) {
    Item item = location.getWorld().dropItem(location, itemStack);
    item.setPickupDelay(Integer.MAX_VALUE);
    item.setMetadata(MetadataHandler.MAJOR_VISUAL_EFFECT_MD, new FixedMetadataValue(plugin, 0));
    item.setGravity(false);
    return item;
}
Also used : Item(org.bukkit.entity.Item) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue)

Aggregations

FixedMetadataValue (org.bukkit.metadata.FixedMetadataValue)56 MinorPowerPowerStance (com.magmaguy.elitemobs.powerstances.MinorPowerPowerStance)22 Entity (org.bukkit.entity.Entity)10 EventHandler (org.bukkit.event.EventHandler)9 LivingEntity (org.bukkit.entity.LivingEntity)7 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)7 Player (org.bukkit.entity.Player)6 ItemStack (org.bukkit.inventory.ItemStack)6 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 Location (org.bukkit.Location)3 Block (org.bukkit.block.Block)3 IronGolem (org.bukkit.entity.IronGolem)3 PotionEffect (org.bukkit.potion.PotionEffect)3 MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Random (java.util.Random)2