From a0640a1e6684e807f6c1e566d4ab865174681806 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 13 Mar 2017 18:12:38 +1100 Subject: [PATCH] Fixes #1536 --- .../plotsquared/bukkit/uuid/SQLUUIDHandler.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLUUIDHandler.java b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLUUIDHandler.java index d8c964854..d322fe9c3 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLUUIDHandler.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLUUIDHandler.java @@ -13,6 +13,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandlerImplementation; import com.intellectualcrafters.plot.uuid.UUIDWrapper; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.HttpURLConnection; @@ -123,15 +124,17 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation { HttpURLConnection connection = (HttpURLConnection) new URL(SQLUUIDHandler.this.PROFILE_URL + uuid.toString().replace("-", "")) .openConnection(); - InputStreamReader reader = new InputStreamReader(connection.getInputStream()); - JSONObject response = (JSONObject) SQLUUIDHandler.this.jsonParser.parse(reader); - String name = (String) response.get("name"); - if (name != null) { - add(new StringWrapper(name), uuid); + try (InputStream con = connection.getInputStream()) { + InputStreamReader reader = new InputStreamReader(con); + JSONObject response = (JSONObject) SQLUUIDHandler.this.jsonParser.parse(reader); + String name = (String) response.get("name"); + if (name != null) { + add(new StringWrapper(name), uuid); + } } } } catch (IOException | ParseException e) { - e.printStackTrace(); + PS.debug("Invalid response from Mojang: Some UUIDs will be cached later. (`unknown` until then or player joins)"); } TaskManager.runTaskLaterAsync(this, SQLUUIDHandler.this.INTERVAL); }