use of org.bukkit.entity.Zombie in project MagicPlugin by elBukkit.
the class GrowEntityAction method perform.
@Override
public SpellResult perform(CastContext context) {
Entity targetEntity = context.getTargetEntity();
MageController controller = context.getController();
if (controller.isElemental(targetEntity)) {
double elementalSize = controller.getElementalScale(targetEntity);
elementalSize *= 1.2;
controller.setElementalScale(targetEntity, elementalSize);
return SpellResult.CAST;
}
if (!(targetEntity instanceof LivingEntity))
return SpellResult.NO_TARGET;
LivingEntity li = (LivingEntity) targetEntity;
if (li instanceof Ageable && !((Ageable) li).isAdult() && !(li instanceof Player)) {
context.registerModified(li);
((Ageable) li).setAdult();
} else if (li instanceof Zombie) {
context.registerModified(li);
Zombie zombie = (Zombie) li;
if (!zombie.isBaby()) {
UndoList spawnedList = com.elmakers.mine.bukkit.block.UndoList.getUndoList(li);
Location targetLocation = li.getLocation();
li.remove();
Entity giant = targetLocation.getWorld().spawnEntity(targetLocation, EntityType.GIANT);
context.registerForUndo(giant);
if (spawnedList != null) {
spawnedList.add(giant);
}
} else {
((Zombie) li).setBaby(false);
}
} else if (li instanceof PigZombie && ((PigZombie) li).isBaby()) {
context.registerModified(li);
((PigZombie) li).setBaby(false);
} else if (li instanceof Slime) {
context.registerModified(li);
Slime slime = (Slime) li;
slime.setSize(slime.getSize() + 1);
} else if (li instanceof Skeleton && skeletons && ((Skeleton) li).getSkeletonType() == Skeleton.SkeletonType.NORMAL) {
context.registerModified(li);
Skeleton skeleton = (Skeleton) li;
skeleton.setSkeletonType(Skeleton.SkeletonType.WITHER);
} else {
return SpellResult.NO_TARGET;
}
return SpellResult.CAST;
}
use of org.bukkit.entity.Zombie in project MagicPlugin by elBukkit.
the class GrowSpell method onCast.
@Override
public SpellResult onCast(ConfigurationSection parameters) {
Target target = getTarget();
if (!target.hasEntity()) {
return SpellResult.NO_TARGET;
}
Entity targetEntity = target.getEntity();
if (controller.isElemental(targetEntity)) {
double elementalSize = controller.getElementalScale(targetEntity);
elementalSize *= 1.2;
controller.setElementalScale(targetEntity, elementalSize);
return SpellResult.CAST;
}
if (!(targetEntity instanceof LivingEntity))
return SpellResult.NO_TARGET;
LivingEntity li = (LivingEntity) targetEntity;
if (li instanceof Ageable && !((Ageable) li).isAdult() && !(li instanceof Player)) {
registerModified(li);
((Ageable) li).setAdult();
} else if (li instanceof Zombie) {
registerModified(li);
Zombie zombie = (Zombie) li;
if (!zombie.isBaby()) {
UndoList spawnedList = com.elmakers.mine.bukkit.block.UndoList.getUndoList(li);
Location targetLocation = li.getLocation();
li.remove();
Entity giant = targetLocation.getWorld().spawnEntity(targetLocation, EntityType.GIANT);
registerForUndo(giant);
if (spawnedList != null) {
spawnedList.add(giant);
}
} else {
((Zombie) li).setBaby(false);
}
} else if (li instanceof PigZombie && ((PigZombie) li).isBaby()) {
registerModified(li);
((PigZombie) li).setBaby(false);
} else if (li instanceof Slime) {
registerModified(li);
Slime slime = (Slime) li;
slime.setSize(slime.getSize() + 1);
} else {
return SpellResult.NO_TARGET;
}
registerForUndo();
return SpellResult.CAST;
}
use of org.bukkit.entity.Zombie in project Citizens2 by CitizensDev.
the class Age method onSpawn.
@Override
public void onSpawn() {
if (npc.getEntity() instanceof Ageable) {
Ageable entity = (Ageable) npc.getEntity();
entity.setAge(age);
entity.setAgeLock(locked);
ageable = entity;
} else if (npc.getEntity() instanceof Zombie) {
((Zombie) npc.getEntity()).setBaby(age < 0);
ageable = null;
} else {
ageable = null;
}
}
use of org.bukkit.entity.Zombie in project Citizens2 by CitizensDev.
the class NPCCommands method age.
@Command(aliases = { "npc" }, usage = "age [age] (-l)", desc = "Set the age of a NPC", help = Messages.COMMAND_AGE_HELP, flags = "l", modifiers = { "age" }, min = 1, max = 2, permission = "citizens.npc.age")
public void age(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
if (!npc.isSpawned() || (!(npc.getEntity() instanceof Ageable) && !(npc.getEntity() instanceof Zombie)))
throw new CommandException(Messages.MOBTYPE_CANNOT_BE_AGED, npc.getName());
Age trait = npc.getTrait(Age.class);
boolean toggleLock = args.hasFlag('l');
if (toggleLock) {
Messaging.sendTr(sender, trait.toggle() ? Messages.AGE_LOCKED : Messages.AGE_UNLOCKED);
}
if (args.argsLength() <= 1) {
if (!toggleLock)
trait.describe(sender);
return;
}
int age = 0;
try {
age = args.getInteger(1);
if (age > 0) {
throw new CommandException(Messages.INVALID_AGE);
}
Messaging.sendTr(sender, Messages.AGE_SET_NORMAL, npc.getName(), age);
} catch (NumberFormatException ex) {
if (args.getString(1).equalsIgnoreCase("baby")) {
age = -24000;
Messaging.sendTr(sender, Messages.AGE_SET_BABY, npc.getName());
} else if (args.getString(1).equalsIgnoreCase("adult")) {
age = 0;
Messaging.sendTr(sender, Messages.AGE_SET_ADULT, npc.getName());
} else
throw new CommandException(Messages.INVALID_AGE);
}
trait.setAge(age);
}
use of org.bukkit.entity.Zombie in project Village_Defense by Plajer.
the class ArenaEvents method onDieEntity.
@EventHandler
public void onDieEntity(EntityDamageByEntityEvent e) {
if (e.getEntity() instanceof LivingEntity && e.getDamager() instanceof Wolf && e.getEntity() instanceof Zombie) {
// trick to get non player killer of zombie
if (!e.getEntity().hasMetadata("VillageEntity"))
return;
if (e.getDamage() >= ((LivingEntity) e.getEntity()).getHealth()) {
Arena arena = ArenaRegistry.getArena(e.getEntity().getMetadata("PlayingArena").get(0).asString());
Player player = (Player) ((Wolf) e.getDamager()).getOwner();
if (player == null)
return;
if (ArenaRegistry.getArena(player) != null) {
arena.addStat(player, "kills");
arena.addExperience(player, 2);
}
}
}
}
Aggregations