use of org.bukkit.entity.Zombie in project Denizen-For-Bukkit by DenizenScript.
the class EntityInfected method setInfected.
public void setInfected(boolean bool) {
if (bool) {
if (infected.isCitizensNPC()) {
NPC infected_npc = infected.getDenizenNPC().getCitizen();
infected_npc.setBukkitEntityType(EntityType.ZOMBIE_VILLAGER);
} else // TODO: Improve upon.
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_11_R1)) {
LivingEntity entity = infected.getLivingEntity();
// Make a new entity
ZombieVillager infect = (ZombieVillager) entity.getLocation().getWorld().spawnEntity(infected.getLocation(), EntityType.ZOMBIE_VILLAGER);
// Set health
infect.setHealth(entity.getHealth());
// Set equipment
infect.getEquipment().setArmorContents(entity.getEquipment().getArmorContents());
// Remove the Villager
entity.remove();
// Set the dEntity to the new entity
infected.setEntity(infect);
} else // TODO: Improve upon.
if (infected.getBukkitEntity() instanceof Villager) {
Villager villager = (Villager) infected.getBukkitEntity();
// Make a new entity
Zombie infect = (Zombie) villager.getLocation().getWorld().spawnEntity(infected.getLocation(), EntityType.ZOMBIE);
infect.setVillager(true);
// Set health
infect.setHealth(villager.getHealth());
// Set equipment
infect.getEquipment().setArmorContents(villager.getEquipment().getArmorContents());
// Remove the Villager
villager.remove();
// Set the dEntity to the new entity
infected.setEntity(infect);
} else // Much much easier
if (infected.getBukkitEntity() instanceof Zombie) {
((Zombie) infected).setVillager(true);
}
}
}
use of org.bukkit.entity.Zombie in project Denizen-For-Bukkit by DenizenScript.
the class EntityAge method setAge.
public void setAge(int val) {
if (ageable.isCitizensNPC()) {
NPC ageable_npc = ageable.getDenizenNPC().getCitizen();
ageable_npc.getTrait(Age.class).setAge(val);
} else {
if (ageable.getBukkitEntity().getType() == EntityType.ZOMBIE) {
((Zombie) ageable.getBukkitEntity()).setBaby(val >= 0);
} else {
((Ageable) ageable.getBukkitEntity()).setAge(val);
}
}
}
use of org.bukkit.entity.Zombie in project Denizen-For-Bukkit by DenizenScript.
the class EntityAge method setBaby.
public void setBaby(boolean bool) {
if (ageable.isCitizensNPC()) {
NPC ageable_npc = ageable.getDenizenNPC().getCitizen();
if (!ageable_npc.hasTrait(Age.class)) {
ageable_npc.addTrait(Age.class);
}
ageable_npc.getTrait(Age.class).setAge(bool ? -24000 : 0);
} else {
if (ageable.getBukkitEntity().getType() == EntityType.ZOMBIE) {
((Zombie) ageable.getBukkitEntity()).setBaby(bool);
} else if (bool) {
((Ageable) ageable.getBukkitEntity()).setBaby();
} else {
((Ageable) ageable.getBukkitEntity()).setAdult();
}
}
}
use of org.bukkit.entity.Zombie 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.entity.Zombie 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);
}
}
Aggregations