use of com.github.games647.craftapi.model.skin.Model in project CraftAPI by games647.
the class AbstractResolver method decodeSkin.
/**
* Decodes the property from a skin request.
*
* @param property Base64 encoded skin property
* @return decoded model
*/
public Skin decodeSkin(SkinProperty property) {
byte[] data = Base64.getDecoder().decode(property.getValue());
String json = new String(data, StandardCharsets.UTF_8);
Skin skinModel = gson.fromJson(json, Skin.class);
skinModel.setSignature(Base64.getDecoder().decode(property.getSignature()));
return skinModel;
}
use of com.github.games647.craftapi.model.skin.Model in project ChangeSkin by games647.
the class MojangSkinApi method parseSkinTexture.
private Optional<SkinModel> parseSkinTexture(Reader reader) {
TexturesModel texturesModel = gson.fromJson(reader, TexturesModel.class);
SkinProperty[] properties = texturesModel.getProperties();
try {
if (properties != null && properties.length > 0) {
SkinProperty propertiesModel = properties[0];
// base64 encoded skin data
String encodedSkin = propertiesModel.getValue();
String signature = propertiesModel.getSignature();
return Optional.of(SkinModel.createSkinFromEncoded(encodedSkin, signature));
}
} catch (Exception ex) {
logger.error("Failed to parse skin model", ex);
logger.error(texturesModel.toString());
}
return Optional.empty();
}
Aggregations