Compare commits
3 Commits
1.0.3+1.16
...
master
Author | SHA1 | Date |
---|---|---|
TheBrokenRail | fcb7df74ed | |
TheBrokenRail | b2ec9ea567 | |
TheBrokenRail | 96860fa2c1 |
|
@ -1,3 +1,5 @@
|
|||
![Poster](images/poster.png)
|
||||
|
||||
# Gestus
|
||||
A server-side mod that adds data-driven emotes to Minecraft that can be viewed by vanilla clients.
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.2 MiB |
|
@ -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,26 +60,40 @@ final class SkinJSON {
|
|||
String data = urlToString(url);
|
||||
|
||||
if (data != null) {
|
||||
Gson gson = new Gson();
|
||||
Response response = gson.fromJson(data, Response.class);
|
||||
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)) {
|
||||
String texturesJSON = new String(Base64.getDecoder().decode(property.value));
|
||||
Data textures = gson.fromJson(texturesJSON, Data.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);
|
||||
|
||||
if (textures.textures.containsKey(SKIN_TEXTURE_KEY)) {
|
||||
Texture skin = textures.textures.get(SKIN_TEXTURE_KEY);
|
||||
return skin.url;
|
||||
if (textures.textures.containsKey(SKIN_TEXTURE_KEY)) {
|
||||
Texture skin = textures.textures.get(SKIN_TEXTURE_KEY);
|
||||
return skin.url;
|
||||
}
|
||||
|
||||
break;
|
||||
} catch (JsonSyntaxException e) {
|
||||
error("Unable To Parse Embedded Skin Metadata: " + uuid.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue