@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));
Optional<TextureModel> capeTexture = Optional.ofNullable(textures.get(TextureType.CAPE));
String skinUrl = skinTexture.map(TextureModel::getShortUrl).orElse("");
String slimModel = skinTexture.map(TextureModel::isSlim).map(slim -> "Alex").orElse("Steve");
String capeUrl = capeTexture.map(TextureModel::getShortUrl).orElse(" - ");
String timeFormat = timeFormatter.format(Instant.ofEpochMilli(timeFetched));
return template.replace("{0}", Integer.toString(rowId))
.replace("{1}", ownerId.toString())
.replace("{2}", ownerName)
.replace("{3}", timeFormat)
.replace("{4}", skinUrl)
.replace("{5}", slimModel)
.replace("{6}", capeUrl);
}
}