This commit is contained in:
Jesse Boyd 2017-03-13 18:12:38 +11:00
parent 0b6d2d3dd6
commit a0640a1e66
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F

View File

@ -13,6 +13,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation; import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
import com.intellectualcrafters.plot.uuid.UUIDWrapper; import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
@ -123,15 +124,17 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
HttpURLConnection connection = HttpURLConnection connection =
(HttpURLConnection) new URL(SQLUUIDHandler.this.PROFILE_URL + uuid.toString().replace("-", "")) (HttpURLConnection) new URL(SQLUUIDHandler.this.PROFILE_URL + uuid.toString().replace("-", ""))
.openConnection(); .openConnection();
InputStreamReader reader = new InputStreamReader(connection.getInputStream()); try (InputStream con = connection.getInputStream()) {
JSONObject response = (JSONObject) SQLUUIDHandler.this.jsonParser.parse(reader); InputStreamReader reader = new InputStreamReader(con);
String name = (String) response.get("name"); JSONObject response = (JSONObject) SQLUUIDHandler.this.jsonParser.parse(reader);
if (name != null) { String name = (String) response.get("name");
add(new StringWrapper(name), uuid); if (name != null) {
add(new StringWrapper(name), uuid);
}
} }
} }
} catch (IOException | ParseException e) { } 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); TaskManager.runTaskLaterAsync(this, SQLUUIDHandler.this.INTERVAL);
} }