use of org.bukkit.entity.Zombie in project Village_Defense by Plajer.
the class ArenaEvents method onDeath.
private void onDeath(final Player player, Arena arena) {
if (arena.getArenaState() == ArenaState.STARTING) {
player.teleport(arena.getStartLocation());
return;
}
if (arena.getArenaState() == ArenaState.ENDING || arena.getArenaState() == ArenaState.RESTARTING) {
player.getInventory().clear();
player.setFlying(false);
player.setAllowFlight(false);
User user = UserManager.getUser(player.getUniqueId());
user.setInt("orbs", 0);
player.teleport(arena.getEndLocation());
return;
}
User user = UserManager.getUser(player.getUniqueId());
arena.addStat(player, "deaths");
arena.teleportToStartLocation(player);
user.setSpectator(true);
player.setGameMode(GameMode.SURVIVAL);
user.setFakeDead(true);
user.setInt("orbs", 0);
ArenaUtils.hidePlayer(player, arena);
player.setAllowFlight(true);
player.getInventory().clear();
MessageHandler.sendTitle(player, ChatColor.stripColor(ChatManager.formatMessage(arena, "In-Game.Death-Screen")), 0, 5 * 20, 0, ChatColor.RED);
if (plugin.is1_9_R1() || plugin.is1_11_R1() || plugin.is1_12_R1()) {
new BukkitRunnable() {
@Override
public void run() {
if (user.isSpectator())
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(ChatManager.formatMessage(arena, ChatManager.colorMessage("In-Game.Died-Respawn-In-Next-Wave"))));
else
this.cancel();
}
}.runTaskTimer(plugin, 20, 20);
}
ChatManager.broadcastDeathMessage(arena, player);
arena.teleportToStartLocation(player);
player.setAllowFlight(true);
player.setFlying(true);
ItemStack spectatorItem = new ItemStack(Material.COMPASS, 1);
ItemMeta spectatorMeta = spectatorItem.getItemMeta();
spectatorMeta.setDisplayName(ChatManager.colorMessage("In-Game.Spectator.Spectator-Item-Name"));
spectatorItem.setItemMeta(spectatorMeta);
player.getInventory().setItem(0, spectatorItem);
player.getInventory().setItem(8, SpecialItemManager.getSpecialItem("Leave").getItemStack());
// tryin to untarget dead player bcuz they will still target him
for (Zombie zombie : arena.getZombies()) {
if (zombie.getTarget() != null) {
if (zombie.getTarget().equals(player)) {
// set new target as villager so zombies won't stay still waiting for nothing
for (Villager villager : arena.getVillagers()) {
zombie.setTarget(villager);
}
}
}
}
}
use of org.bukkit.entity.Zombie in project Village_Defense by Plajer.
the class ArenaInitializer1_12_R1 method spawnHalfInvisibleZombie.
@Override
public void spawnHalfInvisibleZombie(Random random) {
Location location = zombieSpawns.get(random.nextInt(zombieSpawns.size()));
net.minecraft.server.v1_12_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);
zombie.getEquipment().setBoots(new ItemStack(Material.CHAINMAIL_BOOTS));
zombie.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1));
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_12_R1 method spawnGolemBuster.
public void spawnGolemBuster(Random random) {
Location location = zombieSpawns.get(random.nextInt(zombieSpawns.size()));
net.minecraft.server.v1_12_R1.World McWorld = ((CraftWorld) location.getWorld()).getHandle();
GolemBuster fastZombie = new GolemBuster(location.getWorld());
fastZombie.setPosition(location.getX(), location.getY(), location.getZ());
McWorld.addEntity(fastZombie, CreatureSpawnEvent.SpawnReason.CUSTOM);
Zombie zombie = (Zombie) fastZombie.getBukkitEntity();
zombie.getEquipment().setHelmet(new ItemStack(Material.TNT));
zombie.getEquipment().setHelmetDropChance(0.0F);
zombie.getEquipment().setItemInHandDropChance(0F);
zombie.setRemoveWhenFarAway(false);
CreatureUtils.applyHealthBar(zombie);
this.addZombie(zombie);
CreatureUtils.applyMetadata(fastZombie.getBukkitEntity(), this);
super.subtractZombiesToSpawn();
}
use of org.bukkit.entity.Zombie in project Village_Defense by Plajer.
the class ArenaInitializer1_12_R1 method spawnFastZombie.
public void spawnFastZombie(Random random) {
Location location = zombieSpawns.get(random.nextInt(zombieSpawns.size()));
net.minecraft.server.v1_12_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_12_R1 method spawnBabyZombie.
public void spawnBabyZombie(Random random) {
Location location = zombieSpawns.get(random.nextInt(zombieSpawns.size()));
net.minecraft.server.v1_12_R1.World McWorld = ((CraftWorld) location.getWorld()).getHandle();
BabyZombie fastZombie = new BabyZombie(location.getWorld());
fastZombie.setPosition(location.getX(), location.getY(), location.getZ());
Zombie zombie = (Zombie) fastZombie.getBukkitEntity();
CreatureUtils.applyHealthBar(zombie);
zombie.setRemoveWhenFarAway(false);
McWorld.addEntity(fastZombie, CreatureSpawnEvent.SpawnReason.CUSTOM);
this.addZombie((Zombie) fastZombie.getBukkitEntity());
CreatureUtils.applyMetadata(fastZombie.getBukkitEntity(), this);
super.subtractZombiesToSpawn();
}
Aggregations