From 412e8c88ad647628d5255cdb59dc61d451739259 Mon Sep 17 00:00:00 2001 From: LOOHP Date: Tue, 8 Dec 2020 18:30:32 +0800 Subject: [PATCH] Do not use cache if player skin changed --- pom.xml | 2 +- .../Utils/ImageGeneration.java | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 89cf4e07..519f1302 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.loohp InteractiveChatDiscordSrvAddon - 1.2.3.0 + 1.2.3.1 src diff --git a/src/com/loohp/interactivechatdiscordsrvaddon/Utils/ImageGeneration.java b/src/com/loohp/interactivechatdiscordsrvaddon/Utils/ImageGeneration.java index 1b86b3ef..8e1d7b1b 100644 --- a/src/com/loohp/interactivechatdiscordsrvaddon/Utils/ImageGeneration.java +++ b/src/com/loohp/interactivechatdiscordsrvaddon/Utils/ImageGeneration.java @@ -197,15 +197,15 @@ public static BufferedImage getPlayerInventoryImage(Inventory inventory, Player private static BufferedImage getFullBodyImage(Player player) { InteractiveChatDiscordSrvAddon.plugin.imageCounter.incrementAndGet(); try { + JSONObject json = (JSONObject) new JSONParser().parse(SkinUtils.getSkinJsonFromProfile(player)); + String value = ((String) ((JSONObject) ((JSONObject) json.get("textures")).get("SKIN")).get("url")).replace("http://textures.minecraft.net/texture/", ""); + BufferedImage image; - Cache cache = Cache.getCache(player.getUniqueId().toString() + FULL_BODY_IMAGE_KEY); + Cache cache = Cache.getCache(player.getUniqueId().toString() + value + FULL_BODY_IMAGE_KEY); if (cache == null) { - JSONObject json = (JSONObject) new JSONParser().parse(SkinUtils.getSkinJsonFromProfile(player)); - String value = ((String) ((JSONObject) ((JSONObject) json.get("textures")).get("SKIN")).get("url")).replace("http://textures.minecraft.net/texture/", ""); - String url = "https://mc-heads.net/player/" + value + "/61"; image = ImageIO.read(new URL(url)); - Cache.putCache(player.getUniqueId().toString() + FULL_BODY_IMAGE_KEY, image, InteractiveChatDiscordSrvAddon.plugin.cacheTimeout); + Cache.putCache(player.getUniqueId().toString() + value + FULL_BODY_IMAGE_KEY, image, InteractiveChatDiscordSrvAddon.plugin.cacheTimeout); } else { image = (BufferedImage) cache.getObject(); }