private void parsePacket(byte[] data, InetAddress address, int port) throws UnknownHostException {
		String message = new String(data).trim();
		PacketTypes type;
		try {
			if (message.length() < 2) type = PacketTypes.INVALID;
			else type = Packet.lookupPacket(Integer.parseInt(message.substring(0, 2)));
		} catch (NumberFormatException e) {
			type = PacketTypes.INVALID;
		}
		switch (type) {
		case LOGIN: // log new player in from host to new OnlinePlayer
			Packet00Login packet = new Packet00Login(data);
			postOutput("[" + address.getHostAddress() + ":" + port + 
					"] " + packet.username() + " has connected.");
			OnlinePlayer player = new OnlinePlayer(packet.x(), packet.y(), game, 
						packet.username(), address, port, 
						game.getLevel());
			game.addPlayer(player);
			addConnection(player, packet);
			/* response is not being seen
			try {
				Thread.sleep(500);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}*/
			System.out.println("address: " + port);
			Packet10LoginResponse response = new Packet10LoginResponse(
				game.getPlayers(), game.getSettlements(), address, port);
			response.writeData(this);
			break;
		case DISCONNECT: // remove player from connectedPlayers and game
			Packet01Disconnect packet1 = new Packet01Disconnect(data);
			postOutput("[" + address.getHostAddress() + ":" + port + 
								"] " + packet1.username() + " has left.");
			removeConnection(packet1);
			break;
		case MOVE: // move the player
			Packet02Move packet2 = new Packet02Move(data);
			handleMovement(packet2);
			packet2.writeData(this);
			break;
		case SAY:
			Packet03Speech packet3 = new Packet03Speech(data);
			say(packet3);
			System.out.println("saying " + packet3.str());
			break;
		case SETTLEMENT:
			construct(new Packet04Settlement(data));
		case INVALID:
		default: //TODO complain about unrecognised format
			postOutput("INVALID PACKET: " + new PacketXXInvalid(data).str());
			break;
		}
	}