diff --git a/1.9-mcp924-beta1/src/minecraft/net/minecraft/client/resources/SkinManager.java b/1.9-mcp924-beta1/src/minecraft/net/minecraft/client/resources/SkinManager.java index ee699be..d60f87b 100644 --- a/1.9-mcp924-beta1/src/minecraft/net/minecraft/client/resources/SkinManager.java +++ b/1.9-mcp924-beta1/src/minecraft/net/minecraft/client/resources/SkinManager.java @@ -131,14 +131,13 @@ public class SkinManager //CustomSkinLoader Begin if(customskinloader.CustomSkinLoader.config.enable){ - Map newMap=customskinloader.CustomSkinLoader.loadProfile(profile.getName(), map); + Map newMap=customskinloader.CustomSkinLoader.loadProfile(profile.getName(), map); if(!newMap.isEmpty()){ map.clear(); map.putAll(newMap); } } //CustomSkinLoader End - Minecraft.getMinecraft().addScheduledTask(new Runnable() { public void run() @@ -160,7 +159,8 @@ public class SkinManager public Map loadSkinFromCache(GameProfile profile) { - return (Map)this.skinCacheLoader.getUnchecked(profile); + return customskinloader.CustomSkinLoader.loadProfileFromCache(profile.getName()); + //return (Map)this.skinCacheLoader.getUnchecked(profile); } public interface SkinAvailableCallback diff --git a/Common/customskinloader/CustomSkinLoader.java b/Common/customskinloader/CustomSkinLoader.java index 58dd9f9..5e727ff 100644 --- a/Common/customskinloader/CustomSkinLoader.java +++ b/Common/customskinloader/CustomSkinLoader.java @@ -12,6 +12,8 @@ import org.apache.commons.io.IOUtils; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import com.mojang.authlib.minecraft.MinecraftProfileTexture; +import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type; import customskinloader.config.Config; import customskinloader.config.SkinSiteProfile; @@ -25,10 +27,10 @@ import net.minecraft.client.Minecraft; /** * Custom skin loader mod for Minecraft. * @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014-2016 - * @version 13.3 (2016.3.13) + * @version 13.4 (2016.4.3) */ public class CustomSkinLoader { - public static final String CustomSkinLoader_VERSION="13.3"; + public static final String CustomSkinLoader_VERSION="13.4"; public static final File DATA_DIR=new File(Minecraft.getMinecraft().mcDataDir,"CustomSkinLoader"), LOG_FILE=new File(DATA_DIR,"CustomSkinLoader.log"), CONFIG_FILE=new File(DATA_DIR,"CustomSkinLoader.json"); @@ -43,14 +45,33 @@ public class CustomSkinLoader { public static final Logger logger=initLogger(); public static final Config config=loadConfig0(); + private static final Map profileCache=new HashMap(); + + //Entrance public static Map loadProfile(String username,Map defaultProfile){ + String tempName=Thread.currentThread().getName(); + Thread.currentThread().setName(username);//Change Thread Name + UserProfile profile=loadProfile(username,ModelManager0.toUserProfile(defaultProfile)); + Thread.currentThread().setName(tempName); + return ModelManager0.fromUserProfile(profile); + } + public static UserProfile loadProfile(String username,UserProfile defaultProfile){ + logger.info("Loading "+username+"'s profile."); + if(profileCache.get(username)!=null){ + logger.info("Cached profile will be used."); + UserProfile profile=profileCache.get(username); + logger.info(profile.toString()); + return profile; + } + profileCache.put(username, null); for(int i=0;i loadProfileFromCache(String username) { + if(profileCache.containsKey(username)){ + UserProfile profile=profileCache.get(username); return ModelManager0.fromUserProfile(profile); } - return defaultProfile; + return loadProfile(username,(Map)null); } private static Logger initLogger() { diff --git a/Common/customskinloader/Logger.java b/Common/customskinloader/Logger.java index 065d860..a094a92 100644 --- a/Common/customskinloader/Logger.java +++ b/Common/customskinloader/Logger.java @@ -40,15 +40,17 @@ public class Logger { if(level.intValue()>=LOWEST_DISPLAY_LEVEL) System.out.println(msg); try { - writer.write("["); - writer.write(DATE_FORMAT.format(new Date())); - writer.write(" "); - writer.write(Thread.currentThread().getName()); - writer.write(" "); - writer.write(level.getName()); - writer.write("] "); - writer.write(msg); - writer.write("\r\n"); + StringBuilder sb=new StringBuilder(); + sb.append("["); + sb.append(DATE_FORMAT.format(new Date())); + sb.append(" "); + sb.append(Thread.currentThread().getName()); + sb.append(" "); + sb.append(level.getName()); + sb.append("] "); + sb.append(msg); + sb.append("\r\n"); + writer.write(sb.toString()); writer.flush(); } catch (Exception e) { e.printStackTrace(); diff --git a/Common/customskinloader/ModelManager0.java b/Common/customskinloader/ModelManager0.java index 22841bf..0c51e95 100644 --- a/Common/customskinloader/ModelManager0.java +++ b/Common/customskinloader/ModelManager0.java @@ -53,6 +53,8 @@ public class ModelManager0 { */ public static Map fromUserProfile(UserProfile profile){ Map map=Maps.newHashMap(); + if(profile==null) + return map; if(profile.skinUrl!=null){ Map metadata=null; if(profile.model!=null&&profile.model.equals("slim")){