Add Logging
All checks were successful
Gestus/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-08-15 12:51:01 -04:00
parent 17687a3056
commit 96860fa2c1
2 changed files with 36 additions and 15 deletions

View File

@ -97,6 +97,7 @@ public final class SkinColor {
try {
image = ImageIO.read(url);
} catch (IOException e) {
return null;
}

View File

@ -1,6 +1,8 @@
package com.thebrokenrail.gestus.skin;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import org.apache.logging.log4j.LogManager;
import java.io.BufferedReader;
import java.io.IOException;
@ -47,6 +49,10 @@ final class SkinJSON {
}
}
static void error(String data) {
LogManager.getLogger("Gestus").error(data);
}
private static final String SKIN_TEXTURE_KEY = "SKIN";
static String get(UUID uuid) {
@ -54,12 +60,14 @@ final class SkinJSON {
String data = urlToString(url);
if (data != null) {
try {
Gson gson = new Gson();
Response response = gson.fromJson(data, Response.class);
if (response != null && response.properties != null) {
for (Property property : response.properties) {
if ("textures".equals(property.name)) {
try {
String texturesJSON = new String(Base64.getDecoder().decode(property.value));
Data textures = gson.fromJson(texturesJSON, Data.class);
@ -69,11 +77,23 @@ final class SkinJSON {
}
break;
} catch (JsonSyntaxException e) {
error("Unable To Parse Embedded Skin Metadata: " + uuid.toString());
return null;
}
}
}
}
error("Embedded Skin Metadata Is Invalid: " + uuid.toString());
return null;
} catch (JsonSyntaxException e) {
error("Unable To Parse Skin Metadata: " + uuid);
return null;
}
} else {
error("Unable To Download Skin Metadata: " + uuid);
return null;
}
}
}