Compare commits

..

No commits in common. "e91d618dd65811a206ae6fa09a447ce59fcde0f2" and "7fe598539118a0d21290781c413a17f7d434c186" have entirely different histories.

2 changed files with 8 additions and 11 deletions

View file

@ -72,6 +72,7 @@ public class FavoriteAddItem {
final List<Appearance> favorites = profile.getFavorites(); final List<Appearance> favorites = profile.getFavorites();
favorites.add(profile.getAppearance()); favorites.add(profile.getAppearance());
profile.setFavorites(favorites);
dataStore.updateCache(player.getUniqueId(), profile); dataStore.updateCache(player.getUniqueId(), profile);
new FavoritesGUI(player).open(); new FavoritesGUI(player).open();
return true; return true;

View file

@ -105,17 +105,13 @@ public class MojangAPI {
private JsonObject getRequestToUrl(String parametrizedUrl) throws ExecutionException, InterruptedException { private JsonObject getRequestToUrl(String parametrizedUrl) throws ExecutionException, InterruptedException {
return worker.submit(() -> { return worker.submit(() -> {
final URL url = URI.create(parametrizedUrl).toURL(); final URL url = URI.create(parametrizedUrl).toURL();
final HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(); final HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
con.setDoInput(true);
con.setRequestMethod("GET");
connection.setDoInput(true); switch (con.getResponseCode()) {
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: case 403:
logger.warning("The Mojang API denied the request. This should not happen."); logger.warning("Failed to parse request: forbidden?");
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(); return getErrorObject();
case 404: case 404:
case 400: case 400:
@ -125,7 +121,7 @@ public class MojangAPI {
logger.warning("Failed to parse request: The connection is throttled."); logger.warning("Failed to parse request: The connection is throttled.");
return getErrorObject(); return getErrorObject();
case 200: case 200:
final BufferedReader input = new BufferedReader(new InputStreamReader(connection.getInputStream())); final BufferedReader input = new BufferedReader(new InputStreamReader(con.getInputStream()));
final StringBuilder builder = new StringBuilder(); final StringBuilder builder = new StringBuilder();
String line; String line;
while ((line = input.readLine()) != null) { while ((line = input.readLine()) != null) {
@ -140,7 +136,7 @@ public class MojangAPI {
return getErrorObject(); return getErrorObject();
} }
default: default:
logger.warning("Unhandled response code from Mojang: " + connection.getResponseCode()); logger.warning("Unhandled response code from Mojang: " + con.getResponseCode());
return getErrorObject(); return getErrorObject();
} }
}).get(); }).get();