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