use of org.to2mbn.authlibinjector.internal.org.json.JSONArray in project authlib-injector by to2mbn.
the class DeprecatedApiHttpd method queryCharacterUUID.
private Optional<String> queryCharacterUUID(String username) throws UncheckedIOException, JSONException {
String responseText;
try {
responseText = asString(postURL(configuration.getApiRoot() + "api/profiles/minecraft", CONTENT_TYPE_JSON, new JSONArray(new String[] { username }).toString().getBytes(UTF_8)));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
debug("[httpd] query uuid of username {0}, response: {1}", username, responseText);
JSONArray response = new JSONArray(responseText);
if (response.length() == 0) {
return empty();
} else if (response.length() == 1) {
return of(response.getJSONObject(0).getString("id"));
} else {
throw new JSONException("Unexpected response length");
}
}
Aggregations