diff --git a/Common/source/customskinloader/fake/FakeSkinManager.java b/Common/source/customskinloader/fake/FakeSkinManager.java index b6a7d48..8d334f0 100644 --- a/Common/source/customskinloader/fake/FakeSkinManager.java +++ b/Common/source/customskinloader/fake/FakeSkinManager.java @@ -4,6 +4,7 @@ import java.awt.image.BufferedImage; import java.io.File; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; @@ -32,7 +33,7 @@ public class FakeSkinManager { private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(CustomSkinLoader.config.threadPoolSize, CustomSkinLoader.config.threadPoolSize, 1L, TimeUnit.MINUTES, new LinkedBlockingQueue<>()); private final TextureManager textureManager; - private final Map modelCache = new HashMap<>(); + private final Map modelCache = new ConcurrentHashMap<>(); public FakeSkinManager(TextureManager textureManagerInstance, File skinCacheDirectory, MinecraftSessionService sessionService) { this.textureManager = textureManagerInstance; @@ -86,7 +87,14 @@ public class FakeSkinManager { } public Map loadSkinFromCache(GameProfile profile) { - return CustomSkinLoader.loadProfileFromCache(profile); + Map map = new HashMap<>(); + for (Map.Entry entry : CustomSkinLoader.loadProfileFromCache(profile).entrySet()) { + MinecraftProfileTexture texture = this.modelCache.get(this.loadSkin(entry.getValue(), entry.getKey())); // load texture + if (texture != null) { // remove texture if was not loaded before + map.put(entry.getKey(), texture); + } + } + return map; } private static void makeCallback(SkinManager.SkinAvailableCallback callback, MinecraftProfileTexture.Type type, ResourceLocation location, MinecraftProfileTexture texture) {