public static void main(String[] args) throws IOException {
		int port = 51325;
		threads = new ArrayList<ServerThread>();
		persist = new ServerPersistence();
		PlayerManager.init();
		ChannelManager.init();

		System.out.println("MCNSAChat3 Server v1");
		System.out.println("Loading data...");
		load();
		System.out.println("Server Started on port " + port);

		try {
			serverSock = new ServerSocket(port, 0, InetAddress.getByName("0.0.0.0"));
		} catch (IOException e) {
			System.err.println("Could not listen on port " + port);
			System.exit(-1);
		}

		System.out.println("Listening on port " + port);
		new ListenThread().start();
		OnlinePlayersThread onlinePlayersThread = new OnlinePlayersThread();
		onlinePlayersThread.start();

		// start the i/o loop now
		@SuppressWarnings("resource")
		Scanner in = new Scanner(System.in);
		String line = null;
		while ((line = in.nextLine()) != null) {
			if (line.equalsIgnoreCase("stop")) {
				break;
			}
			System.out.println("Unknown command");
		}

		System.out.println("Server is shutting down NOW!");
		System.out.println("WARNING: Threads may take longer to close");
		serverSock.close();
		onlinePlayersThread.interrupt();
		for (ServerThread thread : threads) {
			thread.socket.close();
		}
		System.out.println("Saving data...");
		save();
	}