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);
}
}
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);
}
}
}
}
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));
}
}
}
}
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);
}
}
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;
}
Aggregations