package com.encrox.zombie; import java.util.ArrayList; import java.util.HashMap; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.Sign; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.material.MaterialData; import org.bukkit.util.BlockVector; import com.encrox.instancedregions.InstancedProtectedCuboidRegion; import com.encrox.zombie.interactable.Chest; import com.encrox.zombie.interactable.Interactable; import com.encrox.zombie.interactable.Lever; import com.encrox.zombie.interactable.Powerup; public class Game { private volatile ArrayList players, frozen; private volatile Map map; private volatile HashMap stats; private volatile InstancedProtectedCuboidRegion region; private volatile Mob[] mobs; private volatile ArrayList mobsRound; public volatile ArrayList watchdog; private volatile int round; private volatile boolean done; private volatile Interactable[] inters; private volatile com.sk89q.worldedit.BlockVector min; public Game(ArrayList players, Map map) { this.players = players; this.map = map; stats = new HashMap(); region = Zombie.zombieWorld.allocate(map.getSchematic()); mobs = map.getMobs(); mobsRound = new ArrayList(); watchdog = new ArrayList(); frozen = new ArrayList(); BlockVector spawn = map.getSpawn(); min = region.getMinimumPoint(); Powerup[] powerups = map.getPowerups(); Lever[] levers = map.getLevers(); inters = new Interactable[powerups.length+levers.length+1]; for(int i = 0; i getPlayers() { return players; } public void playerDeath(Player player) { if(!frozen.contains(player)) { announce(ChatColor.RED + Zombie.lang.getProperty("game_player_fell").replace("%player%", player.getName())); player.teleport(player.getLocation().add(0, -1, 0)); player.setHealth(.5); frozen.add(player); Bukkit.getScheduler().runTaskTimer(Zombie.plugin, new Runnable() { int t = 30; @Override public void run() { if(frozen.contains(player)) { if(t == 0) { announce(ChatColor.RED + Zombie.lang.getProperty("game_player_died").replace("%player%", player.getName())); frozen.remove(player); players.remove(player); player.setHealth(player.getMaxHealth()); //TODO: Teleport back outta dungeon } else { announce(ChatColor.YELLOW + Zombie.lang.getProperty("game_revive_countdown").replace("%player%", player.getName()).replace("%seconds%", ""+t)); t-=5; } } } }, 0, 100); } } public boolean isFrozen(Player player) { return frozen.contains(player); } public void revive(Player from, Player to) { if(frozen.contains(to)) { frozen.remove(to); to.teleport(to.getLocation().add(0, -1, 0)); to.setHealth(to.getMaxHealth()); } } public void randomizeChest() { Block block = Zombie.zombieWorld.getWorld().getBlockAt(getAbsoluteLocation(inters[inters.length-1].getBlockVector())); block.setType(Material.AIR); block.getState().update(); Chest relChest = (Chest)Misc.random(map.getChests()); inters[inters.length-1] = relChest; block = Zombie.zombieWorld.getWorld().getBlockAt(getAbsoluteLocation(relChest.getBlockVector())); block.setType(Material.CHEST); org.bukkit.material.Chest c = new org.bukkit.material.Chest(); c.setFacingDirection(relChest.getFacing()); block.setData(c.getData()); block.getState().update(); } public void announce(String text) { for(int i = 0, size = players.size(); i stats.put(k, v+amount)); } public int getPoints(Player player) { if(stats.containsKey(player)) return stats.get(player); return -1; } public Location getAbsoluteLocation(BlockVector relative) { return new Location(Zombie.zombieWorld.getWorld(), min.getX()+relative.getBlockX(), 64+relative.getBlockY(), min.getBlockZ()+relative.getBlockZ()); } /* public Powerup getPowerup(Block block) { for(int i = 0; i