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.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());
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);
}