@Override
	public void run() {
		try {
			ServerSocket server = new ServerSocket(Config.BIND_PORT, 50, InetAddress.getByName(Config.BIND_ADDRESS));
			
			Socket socket;
			while ((socket = server.accept()) != null) {
				try {
					DataInputStream reader = new DataInputStream(socket.getInputStream());

					int packetID = Varint.readVarInt(reader);
					Packet packet = getNewPacket(packetID);
					if (packet == null)
						packet = getNewPacket(Varint.readVarInt(reader));
					
					if (packet == null) {
						System.out.println("Unkown Packet ID received: " + packetID);
						reader.close();
						socket.close();
						continue;
					}

					packet.read(reader);
					DataOutputStream writer = new DataOutputStream(socket.getOutputStream());

					if (packet instanceof Packet254ServerPing)
						this.a( (Packet254ServerPing) packet, reader, writer );
					else if (packet instanceof Packet2Handshake)
						this.a( (Packet2Handshake) packet, writer );
					else if (packet instanceof Packet0Handshake)
						this.a( (Packet0Handshake) packet, reader, writer );

					writer.flush();
					writer.close();
					reader.close();
					socket.close();
				} catch (Exception e) {
					e.printStackTrace();
					continue;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}