diff --git a/Common/source/customskinloader/fake/FakeSkinManager.java b/Common/source/customskinloader/fake/FakeSkinManager.java index 8d334f0..c411187 100644 --- a/Common/source/customskinloader/fake/FakeSkinManager.java +++ b/Common/source/customskinloader/fake/FakeSkinManager.java @@ -2,7 +2,7 @@ package customskinloader.fake; import java.awt.image.BufferedImage; import java.io.File; -import java.util.HashMap; +import java.util.Iterator; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; @@ -87,11 +87,17 @@ public class FakeSkinManager { } public Map loadSkinFromCache(GameProfile 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); + Map map = CustomSkinLoader.loadProfileFromCache(profile); + for (Iterator> it = map.entrySet().iterator(); it.hasNext(); ) { + Map.Entry entry = it.next(); + MinecraftProfileTexture texture = entry.getValue(); + if (shouldJudgeType(texture)) { + texture = this.modelCache.get(this.loadSkin(texture, entry.getKey())); + if (texture == null) { // remove texture if was not loaded before + it.remove(); + } else { + map.put(entry.getKey(), texture); + } } } return map; @@ -102,6 +108,10 @@ public class FakeSkinManager { callback.skinAvailable(type, location, texture); } + private static boolean shouldJudgeType(MinecraftProfileTexture texture) { + return texture != null && "auto".equals(texture.getMetadata("model")); + } + private class BaseBuffer implements IImageBuffer { private IImageBuffer buffer; @@ -133,7 +143,7 @@ public class FakeSkinManager { public void skinAvailable() { if (buffer != null) { buffer.skinAvailable(); - if ("auto".equals(texture.getMetadata("model")) && buffer instanceof FakeSkinBuffer) { + if (shouldJudgeType(texture) && buffer instanceof FakeSkinBuffer) { //Auto judge skin type Map metadata = Maps.newHashMap(); String type = ((FakeSkinBuffer) buffer).judgeType();