use of com.github.games647.changeskin.core.model.skin.TextureType in project ChangeSkin by games647.
the class SkinFormatter method apply.
@Override
public String apply(String template, SkinModel skin) {
if (template == null) {
return null;
}
int rowId = skin.getRowId();
UUID ownerId = skin.getProfileId();
String ownerName = skin.getProfileName();
long timeFetched = skin.getTimestamp();
Map<TextureType, TextureModel> textures = skin.getTextures();
Optional<TextureModel> skinTexture = Optional.ofNullable(textures.get(TextureType.SKIN));
String skinUrl = skinTexture.map(TextureModel::getUrl).orElse("");
String metadata = skinTexture.map(TextureModel::getMetadata).map(MetadataModel::getModel).orElse("");
String capeUrl = Optional.ofNullable(textures.get(TextureType.CAPE)).map(TextureModel::getUrl).orElse("");
String time = LocalDateTime.ofInstant(Instant.ofEpochMilli(timeFetched), ZoneId.systemDefault()).toString();
return template.replace("{0}", Integer.toString(rowId)).replace("{1}", ownerId.toString()).replace("{2}", ownerName).replace("{3}", time).replace("{4}", skinUrl).replace("{5}", metadata).replace("{6}", capeUrl);
}
Aggregations