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