@Override public void onEnable() { plugin = this; // Load all YML files ConfigManager.loadConfig(this); ChestClassManager.loadConfig(this); DataManager.loadDatabase(this); PlayerDataManager.loadPlayerData(this); // Load listeners if (ConfigManager.getPvP()) { new AntiPvPListener(); } new ArenaProtectionListener(); new PlayerRespawnListener(); // Load commands CommandHandler.loadCommands(this); PluginDescriptionFile pdf = getDescription(); logger.info("[" + pdf.getName() + "] version " + pdf.getVersion() + " is enabled!"); }
public class Countdown extends ChatVariableHolder implements Runnable { private Game game; private int time = ConfigManager.getCountdown(); public Countdown(Game game) { this.game = game; game.setStatus(Status.COUNTDOWN); prepareWorld(); prepareTributes(); new Thread(this).start(); } @Override public void run() { final Set<Player> tributes = game.getTributes(); while (time > 0) { if (time < 11 || time % 10 == 0) { for (Player p : tributes) { p.sendMessage(prefix + GREEN + "The game begins in " + time + " seconds!"); } } try { Thread.sleep(1000); } catch (Exception wtf) { wtf.printStackTrace(); } time--; } Bukkit.getServer() .broadcastMessage( prefix + YELLOW + "A game has begun in arena " + BLUE + game.getArena().getName() + "!"); for (Player p : tributes) { p.sendMessage(prefix + GREEN + "May the odds be ever in your favor!"); } game.startGame(); } public void prepareTributes() { Collection<Location> spawns = game.getArena().getWarps().getSpawns().values(); Set<Player> tributes = game.getTributes(); Iterator<Location> i = spawns.iterator(); String list = prefix + GREEN + "Tributes: "; for (Player p : tributes) { list += RED + p.getName() + WHITE + ", "; p.teleport(i.next()); Players.clearInv(p); Players.heal(p); } list = list.substring(0, list.length() - 2); for (Player p : tributes) { p.sendMessage(prefix + GREEN + "The countdown has begun!"); p.sendMessage(list); } } public void prepareWorld() { game.getArena().getWorld().setTime(0); game.getArena().fillChests(); for (Entity e : game.getArena().getWorld().getEntities()) { if (e instanceof Monster || e instanceof Slime) { Bukkit.getPluginManager() .callEvent(new EntityDeathEvent((LivingEntity) e, Collections.<ItemStack>emptyList())); e.remove(); } } } }