diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java index f79ef8aaf..f2f8f4038 100644 --- a/src/main/java/fr/xephi/authme/AuthMe.java +++ b/src/main/java/fr/xephi/authme/AuthMe.java @@ -863,29 +863,31 @@ public class AuthMe extends JavaPlugin { Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable(){ @Override public void run() { - String realIP = player.getAddress().getAddress().getHostAddress(); - String sUrl = "http://monitor-1.verygames.net/api/?action=ipclean-real-ip&out=raw&ip=%IP%&port=%PORT%"; - sUrl = sUrl.replace("%IP%", realIP) - .replace("%PORT%", "" + player.getAddress().getPort()); - try { - URL url = new URL(sUrl); - URLConnection urlCon = url.openConnection(); - try (BufferedReader in = new BufferedReader(new InputStreamReader(urlCon.getInputStream()))) { - String inputLine = in.readLine(); - if (!StringUtils.isEmpty(inputLine) && !inputLine.equalsIgnoreCase("error") - && !inputLine.contains("error")) { - realIP = inputLine; - } - } catch (IOException e) { - ConsoleLogger.showError("Could not read from Very Games API - " + StringUtils.formatException(e)); - } - } catch (IOException e) { - ConsoleLogger.showError("Could not fetch Very Games API with URL '" + sUrl + "' - " - + StringUtils.formatException(e)); - } - if (realIp.containsKey(name)) - realIp.remove(name); - realIp.putIfAbsent(name, realIP); + String realIP = player.getAddress().getAddress().getHostAddress(); + if (realIp.containsKey(name)) + realIP = realIp.get(name); + String sUrl = "http://monitor-1.verygames.net/api/?action=ipclean-real-ip&out=raw&ip=%IP%&port=%PORT%"; + sUrl = sUrl.replace("%IP%", realIP) + .replace("%PORT%", "" + player.getAddress().getPort()); + try { + URL url = new URL(sUrl); + URLConnection urlCon = url.openConnection(); + try (BufferedReader in = new BufferedReader(new InputStreamReader(urlCon.getInputStream()))) { + String inputLine = in.readLine(); + if (!StringUtils.isEmpty(inputLine) && !inputLine.equalsIgnoreCase("error") + && !inputLine.contains("error")) { + realIP = inputLine; + } + } catch (IOException e) { + ConsoleLogger.showError("Could not read from Very Games API - " + StringUtils.formatException(e)); + } + } catch (IOException e) { + ConsoleLogger.showError("Could not fetch Very Games API with URL '" + sUrl + "' - " + + StringUtils.formatException(e)); + } + if (realIp.containsKey(name)) + realIp.remove(name); + realIp.putIfAbsent(name, realIP); } }); }