From dc395cdc3f28ae80b95db02da9880c0a7f86c5ac Mon Sep 17 00:00:00 2001 From: games647 Date: Wed, 20 Jul 2016 20:03:17 +0200 Subject: [PATCH] Remove debug code --- .../fastlogin/core/MojangApiConnector.java | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/core/src/main/java/com/github/games647/fastlogin/core/MojangApiConnector.java b/core/src/main/java/com/github/games647/fastlogin/core/MojangApiConnector.java index 15b62904..13945bca 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/MojangApiConnector.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/MojangApiConnector.java @@ -83,37 +83,37 @@ public abstract class MojangApiConnector { */ public UUID getPremiumUUID(String playerName) { //check if it's a valid playername -// if (playernameMatcher.matcher(playerName).matches()) { - //only make a API call if the name is valid existing mojang account + if (playernameMatcher.matcher(playerName).matches()) { +// only make a API call if the name is valid existing mojang account -// if (requests.size() >= rateLimit || System.currentTimeMillis() - lastRateLimit < 1_000 * 60 * 10) { + if (requests.size() >= rateLimit || System.currentTimeMillis() - lastRateLimit < 1_000 * 60 * 10) { // plugin.getLogger().fine("STILL WAITING FOR RATE_LIMIT - TRYING Third-party API"); return getUUIDFromAPI(playerName); -// } + } -// requests.put(new Object(), new Object()); -// -// try { -// HttpsURLConnection connection = getConnection(UUID_LINK + playerName); -// if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) { -// BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); -// String line = reader.readLine(); -// if (line != null && !line.equals("null")) { -// return getUUIDFromJson(line); -// } -// } else if (connection.getResponseCode() == RATE_LIMIT_CODE) { -// logger.info("RATE_LIMIT REACHED - TRYING THIRD-PARTY API"); -// lastRateLimit = System.currentTimeMillis(); -// return getUUIDFromAPI(playerName); -// } -// //204 - no content for not found -// } catch (Exception ex) { -// logger.log(Level.SEVERE, "Failed to check if player has a paid account", ex); -// } -// //this connection doesn't need to be closed. So can make use of keep alive in java -// } -// -// return null; + requests.put(new Object(), new Object()); + + try { + HttpsURLConnection connection = getConnection(UUID_LINK + playerName); + if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) { + BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String line = reader.readLine(); + if (line != null && !line.equals("null")) { + return getUUIDFromJson(line); + } + } else if (connection.getResponseCode() == RATE_LIMIT_CODE) { + logger.info("RATE_LIMIT REACHED - TRYING THIRD-PARTY API"); + lastRateLimit = System.currentTimeMillis(); + return getUUIDFromAPI(playerName); + } + //204 - no content for not found + } catch (Exception ex) { + logger.log(Level.SEVERE, "Failed to check if player has a paid account", ex); + } + //this connection doesn't need to be closed. So can make use of keep alive in java + } + + return null; } public UUID getUUIDFromAPI(String playerName) {