use of org.bukkit.entity.Zombie in project Village_Defense by Plajer.
the class ArenaInitializer1_11_R1 method spawnFastZombie.
public void spawnFastZombie(Random random) {
Location location = zombieSpawns.get(random.nextInt(zombieSpawns.size()));
net.minecraft.server.v1_11_R1.World McWorld = ((CraftWorld) location.getWorld()).getHandle();
FastZombie fastZombie = new FastZombie(location.getWorld());
fastZombie.setPosition(location.getX(), location.getY(), location.getZ());
McWorld.addEntity(fastZombie, CreatureSpawnEvent.SpawnReason.CUSTOM);
Zombie zombie = (Zombie) fastZombie.getBukkitEntity();
zombie.setRemoveWhenFarAway(false);
CreatureUtils.applyHealthBar(zombie);
this.addZombie((Zombie) fastZombie.getBukkitEntity());
CreatureUtils.applyMetadata(fastZombie.getBukkitEntity(), this);
super.subtractZombiesToSpawn();
}
use of org.bukkit.entity.Zombie in project Village_Defense by Plajer.
the class ArenaInitializer1_11_R1 method spawnSoftHardZombie.
@Override
public void spawnSoftHardZombie(Random random) {
Location location = zombieSpawns.get(random.nextInt(zombieSpawns.size()));
net.minecraft.server.v1_11_R1.World McWorld = ((CraftWorld) location.getWorld()).getHandle();
HardZombie fastZombie = new HardZombie(location.getWorld());
fastZombie.setPosition(location.getX(), location.getY(), location.getZ());
McWorld.addEntity(fastZombie, CreatureSpawnEvent.SpawnReason.CUSTOM);
Zombie zombie = (Zombie) fastZombie.getBukkitEntity();
zombie.getEquipment().setBoots(new ItemStack(Material.IRON_BOOTS));
zombie.getEquipment().setLeggings(new ItemStack(Material.IRON_LEGGINGS));
zombie.getEquipment().setChestplate(new ItemStack(Material.IRON_CHESTPLATE));
zombie.getEquipment().setHelmet(new ItemStack(Material.IRON_HELMET));
zombie.setRemoveWhenFarAway(false);
CreatureUtils.applyHealthBar(zombie);
CreatureUtils.applyMetadata(fastZombie.getBukkitEntity(), this);
this.addZombie(zombie);
super.subtractZombiesToSpawn();
}
use of org.bukkit.entity.Zombie in project Village_Defense by Plajer.
the class WizardKit method onStaffUse.
@EventHandler
public void onStaffUse(PlayerInteractEvent e) {
if (UserManager.getUser(e.getPlayer().getUniqueId()) == null)
return;
if (ArenaRegistry.getArena(e.getPlayer()) == null)
return;
if (!(UserManager.getUser(e.getPlayer().getUniqueId()).getKit() instanceof WizardKit))
return;
final Player p = e.getPlayer();
ItemStack is = e.getPlayer().getItemInHand();
if (is != null && is.hasItemMeta() && is.getItemMeta().hasDisplayName()) {
if (is.getItemMeta().getDisplayName().equals(ChatManager.colorMessage("Kits.Wizard.Essence-Item-Name"))) {
if (UserManager.getUser(e.getPlayer().getUniqueId()).getCooldown("essence") > 0 && !UserManager.getUser(e.getPlayer().getUniqueId()).isSpectator()) {
String msgstring = ChatManager.colorMessage("Kits.Ability-Still-On-Cooldown");
msgstring = msgstring.replaceFirst("%COOLDOWN%", Long.toString(UserManager.getUser(e.getPlayer().getUniqueId()).getCooldown("essence")));
e.getPlayer().sendMessage(msgstring);
return;
}
wizardsOnDuty.add(p);
if (p.getMaxHealth() > (p.getHealth() + 3)) {
p.setHealth(p.getHealth() + 3);
} else {
p.setHealth(p.getMaxHealth());
}
if (p.getItemInHand().getAmount() <= 1) {
ItemStack essenceOfDarkness = new ItemStack(Material.INK_SACK, 1);
List<String> essenceLore = Util.splitString(ChatManager.colorMessage("Kits.Wizard.Essence-Item-Lore"), 40);
this.setItemNameAndLore(essenceOfDarkness, ChatManager.colorMessage("Kits.Wizard.Essence-Item-Name"), essenceLore.toArray(new String[essenceLore.size()]));
p.setItemInHand(essenceOfDarkness);
} else {
p.getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
}
if (plugin.is1_9_R1() || plugin.is1_11_R1() || plugin.is1_12_R1()) {
p.getWorld().spawnParticle(Particle.CRIT_MAGIC, p.getLocation(), 30, 1, 1, 1);
}
for (Entity en : p.getNearbyEntities(2, 2, 2)) {
if (en instanceof Zombie) {
((Zombie) en).damage(9.0, p);
}
}
Bukkit.getScheduler().runTaskLater(plugin, () -> wizardsOnDuty.remove(p), 20 * 15);
UserManager.getUser(e.getPlayer().getUniqueId()).setCooldown("essence", 15);
}
if (is.getItemMeta().getDisplayName().equals(ChatManager.colorMessage("Kits.Wizard.Staff-Item-Name"))) {
if (UserManager.getUser(e.getPlayer().getUniqueId()).isSpectator()) {
e.getPlayer().sendMessage(ChatManager.colorMessage("Kits.Cleaner.Spectator-Warning"));
return;
}
if (UserManager.getUser(e.getPlayer().getUniqueId()).getCooldown("wizard_staff") > 0 && !UserManager.getUser(e.getPlayer().getUniqueId()).isSpectator()) {
String msgstring = ChatManager.colorMessage("Kits.Ability-Still-On-Cooldown");
msgstring = msgstring.replaceFirst("%COOLDOWN%", Long.toString(UserManager.getUser(e.getPlayer().getUniqueId()).getCooldown("wizard_staff")));
e.getPlayer().sendMessage(msgstring);
return;
}
new BukkitRunnable() {
double t = 0;
Location loc = p.getLocation();
Vector direction = loc.getDirection().normalize();
@Override
public void run() {
t += 0.5;
double x = direction.getX() * t;
double y = direction.getY() * t + 1.5;
double z = direction.getZ() * t;
loc.add(x, y, z);
if (plugin.is1_9_R1() || plugin.is1_11_R1() || plugin.is1_12_R1()) {
p.getWorld().spawnParticle(Particle.TOWN_AURA, loc, 5);
}
for (Entity en : loc.getChunk().getEntities()) {
if (!(en instanceof LivingEntity && en instanceof Zombie))
continue;
if (en.getLocation().distance(loc) < 1.0) {
if (!en.equals(p)) {
((LivingEntity) en).damage(6.0, p);
}
}
}
loc.subtract(x, y, z);
if (t > 40) {
this.cancel();
}
}
}.runTaskTimer(plugin, 0, 1);
UserManager.getUser(e.getPlayer().getUniqueId()).setCooldown("wizard_staff", 1);
}
}
}
use of org.bukkit.entity.Zombie in project MagicPlugin by elBukkit.
the class ShrinkEntityAction 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);
if (elementalSize < 0.1) {
return super.perform(context);
}
elementalSize /= 2;
controller.setElementalScale(targetEntity, elementalSize);
return SpellResult.CAST;
}
if (!(targetEntity instanceof LivingEntity))
return SpellResult.NO_TARGET;
LivingEntity li = (LivingEntity) targetEntity;
boolean alreadyDead = li.isDead() || li.getHealth() <= 0;
String itemName = CompatibilityLib.getDeprecatedUtils().getDisplayName(li) + " Head";
EntityType replaceType = null;
boolean handled = true;
CompatibilityUtils compatibilityUtils = CompatibilityLib.getCompatibilityUtils();
if (li instanceof Player) {
super.perform(context);
if (li.isDead() && !alreadyDead && dropSkull) {
dropHead(context, targetEntity, itemName);
}
} else if (li.getType() == EntityType.GIANT) {
replaceType = EntityType.ZOMBIE;
} else if (li instanceof Ageable && ((Ageable) li).isAdult()) {
context.registerModified(li);
((Ageable) li).setBaby();
} else if (li instanceof Zombie && compatibilityUtils.isAdult((Zombie) li)) {
context.registerModified(li);
compatibilityUtils.setBaby((Zombie) li);
} else if (li instanceof Slime && ((Slime) li).getSize() > 1) {
context.registerModified(li);
Slime slime = (Slime) li;
slime.setSize(slime.getSize() - 1);
} else if (li instanceof Slime && ((Slime) li).getSize() > 1) {
context.registerModified(li);
Slime slime = (Slime) li;
slime.setSize(slime.getSize() - 1);
} else if (li.getType().name().equals("WITHER_SKELETON") && skeletons) {
replaceType = EntityType.SKELETON;
} else if (li.getType().name().equals("PHANTOM")) {
int size = compatibilityUtils.getPhantomSize(li);
if (size > 1) {
compatibilityUtils.setPhantomSize(li, size - 1);
} else {
handled = false;
}
} else {
handled = false;
}
if (!handled) {
super.perform(context);
if ((li.isDead() || li.getHealth() == 0) && !alreadyDead && dropSkull) {
dropHead(context, targetEntity, itemName);
}
}
if (replaceType != null) {
UndoList spawnedList = com.elmakers.mine.bukkit.block.UndoList.getUndoList(li);
context.registerModified(li);
Entity replacement = controller.replaceMob(li, new EntityData(controller, replaceType), true, CreatureSpawnEvent.SpawnReason.CUSTOM);
if (replacement == null) {
return SpellResult.FAIL;
}
if (replacement instanceof Zombie) {
compatibilityUtils.setAdult((Zombie) replacement);
}
context.registerForUndo(replacement);
if (spawnedList != null) {
spawnedList.add(replacement);
}
}
return SpellResult.CAST;
}
use of org.bukkit.entity.Zombie in project MagicPlugin by elBukkit.
the class ShrinkSpell method onCast.
@Override
public SpellResult onCast(ConfigurationSection parameters) {
String giveName = parameters.getString("name");
if (giveName != null) {
String itemName = giveName + "'s Head";
dropHead(controller, getLocation(), giveName, itemName);
return SpellResult.CAST;
}
Target target = getTarget();
if (target.hasEntity()) {
Entity targetEntity = target.getEntity();
if (controller.isElemental(targetEntity)) {
double elementalSize = controller.getElementalScale(targetEntity);
if (elementalSize < 0.1) {
int elementalDamage = parameters.getInt("elemental_damage", DEFAULT_ENTITY_DAMAGE);
controller.damageElemental(targetEntity, elementalDamage, 0, mage.getCommandSender());
} else {
elementalSize /= 2;
controller.setElementalScale(targetEntity, elementalSize);
}
return SpellResult.CAST;
}
if (!(targetEntity instanceof LivingEntity))
return SpellResult.NO_TARGET;
// Register for undo in advance to catch entity death.
registerForUndo();
int damage = parameters.getInt("entity_damage", DEFAULT_ENTITY_DAMAGE);
LivingEntity li = (LivingEntity) targetEntity;
boolean alreadyDead = li.isDead() || li.getHealth() <= 0;
String itemName = CompatibilityLib.getDeprecatedUtils().getDisplayName(li) + " Head";
;
if (li instanceof Player) {
damage = parameters.getInt("player_damage", DEFAULT_PLAYER_DAMAGE);
}
Location targetLocation = targetEntity.getLocation();
if (li instanceof Player) {
CompatibilityLib.getCompatibilityUtils().magicDamage(li, damage, mage.getEntity());
if (li.isDead() && !alreadyDead) {
dropHead(controller, targetEntity, itemName);
}
} else if (li.getType() == EntityType.GIANT) {
UndoList spawnedList = com.elmakers.mine.bukkit.block.UndoList.getUndoList(li);
registerModified(li);
li.remove();
Entity zombie = targetLocation.getWorld().spawnEntity(targetLocation, EntityType.ZOMBIE);
if (zombie instanceof Zombie) {
((Zombie) zombie).setBaby(false);
}
registerForUndo(zombie);
if (spawnedList != null) {
spawnedList.add(zombie);
}
} else if (li instanceof Ageable && ((Ageable) li).isAdult() && !(li instanceof Player)) {
registerModified(li);
((Ageable) li).setBaby();
} else if (li instanceof Zombie && !((Zombie) li).isBaby()) {
registerModified(li);
((Zombie) li).setBaby(true);
} else if (li instanceof PigZombie && !((PigZombie) li).isBaby()) {
registerModified(li);
((PigZombie) li).setBaby(true);
} else if (li instanceof Slime && ((Slime) li).getSize() > 1) {
registerModified(li);
Slime slime = (Slime) li;
slime.setSize(slime.getSize() - 1);
} else {
CompatibilityLib.getCompatibilityUtils().magicDamage(li, damage, mage.getEntity());
if ((li.isDead() || li.getHealth() == 0) && !alreadyDead) {
dropHead(controller, targetEntity, itemName);
}
}
} else {
Block targetBlock = target.getBlock();
if (targetBlock == null) {
return SpellResult.NO_TARGET;
}
String blockSkin = getBlockSkin(targetBlock.getType());
if (blockSkin == null)
return SpellResult.NO_TARGET;
if (!hasBreakPermission(targetBlock)) {
return SpellResult.INSUFFICIENT_PERMISSION;
}
if (mage.isIndestructible(targetBlock)) {
return SpellResult.NO_TARGET;
}
registerForUndo(targetBlock);
registerForUndo();
dropHead(controller, targetBlock.getLocation(), blockSkin, targetBlock.getType().name());
targetBlock.setType(Material.AIR);
}
return SpellResult.CAST;
}
Aggregations