cache the skin image
All checks were successful
deploy / deploy (push) Successful in 42s

This commit is contained in:
Lee 2024-04-08 06:36:35 +01:00
parent e90f409ce9
commit d3adb6815d
2 changed files with 9 additions and 1 deletions

@ -1,6 +1,7 @@
package cc.fascinated.model.player; package cc.fascinated.model.player;
import cc.fascinated.config.Config; import cc.fascinated.config.Config;
import cc.fascinated.util.PlayerUtils;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -28,6 +29,11 @@ public class Skin {
*/ */
private final Model model; private final Model model;
/**
* The skin data of the skin
*/
private final byte[] skinData;
/** /**
* The part URLs of the skin * The part URLs of the skin
*/ */
@ -37,6 +43,8 @@ public class Skin {
public Skin(String url, Model model) { public Skin(String url, Model model) {
this.url = url; this.url = url;
this.model = model; this.model = model;
this.skinData = PlayerUtils.getSkinData(url);
} }
/** /**

@ -46,7 +46,7 @@ public class PlayerUtils {
} }
try { try {
BufferedImage image = ImageIO.read(new ByteArrayInputStream(PlayerUtils.getSkinData(skin.getUrl()))); BufferedImage image = ImageIO.read(new ByteArrayInputStream(skin.getSkinData()));
if (image == null) { if (image == null) {
return null; return null;
} }