From d3adb6815d40d4c02cd4b103df7cc54be4499200 Mon Sep 17 00:00:00 2001 From: Liam Date: Mon, 8 Apr 2024 06:36:35 +0100 Subject: [PATCH] cache the skin image --- src/main/java/cc/fascinated/model/player/Skin.java | 8 ++++++++ src/main/java/cc/fascinated/util/PlayerUtils.java | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/cc/fascinated/model/player/Skin.java b/src/main/java/cc/fascinated/model/player/Skin.java index c2ea590..cd593c0 100644 --- a/src/main/java/cc/fascinated/model/player/Skin.java +++ b/src/main/java/cc/fascinated/model/player/Skin.java @@ -1,6 +1,7 @@ package cc.fascinated.model.player; import cc.fascinated.config.Config; +import cc.fascinated.util.PlayerUtils; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.gson.JsonObject; import lombok.AllArgsConstructor; @@ -28,6 +29,11 @@ public class Skin { */ private final Model model; + /** + * The skin data of the skin + */ + private final byte[] skinData; + /** * The part URLs of the skin */ @@ -37,6 +43,8 @@ public class Skin { public Skin(String url, Model model) { this.url = url; this.model = model; + + this.skinData = PlayerUtils.getSkinData(url); } /** diff --git a/src/main/java/cc/fascinated/util/PlayerUtils.java b/src/main/java/cc/fascinated/util/PlayerUtils.java index d1e7071..e134218 100644 --- a/src/main/java/cc/fascinated/util/PlayerUtils.java +++ b/src/main/java/cc/fascinated/util/PlayerUtils.java @@ -46,7 +46,7 @@ public class PlayerUtils { } try { - BufferedImage image = ImageIO.read(new ByteArrayInputStream(PlayerUtils.getSkinData(skin.getUrl()))); + BufferedImage image = ImageIO.read(new ByteArrayInputStream(skin.getSkinData())); if (image == null) { return null; }