Skip to content

Commit

Permalink
Do not use cache if player skin changed
Browse files Browse the repository at this point in the history
  • Loading branch information
LOOHP committed Dec 8, 2020
1 parent 66aaec4 commit 412e8c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.loohp</groupId>
<artifactId>InteractiveChatDiscordSrvAddon</artifactId>
<version>1.2.3.0</version>
<version>1.2.3.1</version>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 412e8c8

Please sign in to comment.