Compare commits
2 commits
7fe5985391
...
e91d618dd6
Author | SHA1 | Date | |
---|---|---|---|
e91d618dd6 | |||
1a169f7709 |
2 changed files with 11 additions and 8 deletions
|
@ -72,7 +72,6 @@ public class FavoriteAddItem {
|
|||
|
||||
final List<Appearance> favorites = profile.getFavorites();
|
||||
favorites.add(profile.getAppearance());
|
||||
profile.setFavorites(favorites);
|
||||
dataStore.updateCache(player.getUniqueId(), profile);
|
||||
new FavoritesGUI(player).open();
|
||||
return true;
|
||||
|
|
|
@ -105,13 +105,17 @@ public class MojangAPI {
|
|||
private JsonObject getRequestToUrl(String parametrizedUrl) throws ExecutionException, InterruptedException {
|
||||
return worker.submit(() -> {
|
||||
final URL url = URI.create(parametrizedUrl).toURL();
|
||||
final HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
con.setDoInput(true);
|
||||
con.setRequestMethod("GET");
|
||||
final HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||
|
||||
switch (con.getResponseCode()) {
|
||||
connection.setDoInput(true);
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0");
|
||||
connection.setRequestMethod("GET");
|
||||
|
||||
switch (connection.getResponseCode()) {
|
||||
case 403:
|
||||
logger.warning("Failed to parse request: forbidden?");
|
||||
logger.warning("The Mojang API denied the request. This should not happen.");
|
||||
logger.warning("Nicko is NOT responsible for this error. Try again in a few minutes or hours.");
|
||||
logger.warning("See https://bugs.mojang.com/browse/WEB/issues/WEB-7591 for more info.");
|
||||
return getErrorObject();
|
||||
case 404:
|
||||
case 400:
|
||||
|
@ -121,7 +125,7 @@ public class MojangAPI {
|
|||
logger.warning("Failed to parse request: The connection is throttled.");
|
||||
return getErrorObject();
|
||||
case 200:
|
||||
final BufferedReader input = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
final BufferedReader input = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
String line;
|
||||
while ((line = input.readLine()) != null) {
|
||||
|
@ -136,7 +140,7 @@ public class MojangAPI {
|
|||
return getErrorObject();
|
||||
}
|
||||
default:
|
||||
logger.warning("Unhandled response code from Mojang: " + con.getResponseCode());
|
||||
logger.warning("Unhandled response code from Mojang: " + connection.getResponseCode());
|
||||
return getErrorObject();
|
||||
}
|
||||
}).get();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue