public void removeFloodProtection(String ip) {
   if (!Config.FLOOD_PROTECTION) return;
   ForeignConnection fConnection = _floodProtection.get(ip);
   if (fConnection != null) {
     fConnection.connectionNumber -= 1;
     if (fConnection.connectionNumber == 0) {
       _floodProtection.remove(ip);
     }
   } else {
     _log.warning(
         "Removing a flood protection for a GameServer that was not in the connection map??? :"
             + ip);
   }
 }
  @Override
  public void run() {
    Socket connection = null;

    while (true) {
      try {
        connection = _serverSocket.accept();
        if (Config.FLOOD_PROTECTION) {
          ForeignConnection fConnection =
              _floodProtection.get(connection.getInetAddress().getHostAddress());
          if (fConnection != null) {
            fConnection.connectionNumber += 1;
            if ((fConnection.connectionNumber > Config.FAST_CONNECTION_LIMIT
                    && (System.currentTimeMillis() - fConnection.lastConnection)
                        < Config.NORMAL_CONNECTION_TIME)
                || (System.currentTimeMillis() - fConnection.lastConnection)
                    < Config.FAST_CONNECTION_TIME
                || fConnection.connectionNumber > Config.MAX_CONNECTION_PER_IP) {
              fConnection.lastConnection = System.currentTimeMillis();
              connection.close();
              fConnection.connectionNumber -= 1;
              if (!fConnection.isFlooding)
                _log.warning(
                    "Potential Flood from " + connection.getInetAddress().getHostAddress());
              fConnection.isFlooding = true;
              continue;
            }
            if (fConnection
                .isFlooding) // if connection was flooding server but now passed the check
            {
              fConnection.isFlooding = false;
              _log.info(
                  connection.getInetAddress().getHostAddress()
                      + " is not considered as flooding anymore.");
            }
            fConnection.lastConnection = System.currentTimeMillis();
          } else {
            fConnection = new ForeignConnection(System.currentTimeMillis());
            _floodProtection.put(connection.getInetAddress().getHostAddress(), fConnection);
          }
        }
        addClient(connection);
      } catch (Exception e) {
        try {
          connection.close();
        } catch (Exception e2) {
        }
        if (this.isInterrupted()) {
          // shutdown?
          try {
            _serverSocket.close();
          } catch (IOException io) {
            _log.log(Level.INFO, "", io);
          }
          break;
        }
      }
    }
  }