From 4ebce88594bfaa22db3a445b869123172c06fd9f Mon Sep 17 00:00:00 2001 From: Alexander Xia Date: Sun, 3 Apr 2016 16:29:00 +0800 Subject: [PATCH] Fixed crash when skull texture not found Added switch for cache --- .../customskinloader/ModelManager0.java | 2 ++ Common/customskinloader/CustomSkinLoader.java | 22 ++++++------------- Common/customskinloader/ModelManager0.java | 2 ++ Common/customskinloader/config/Config.java | 1 + 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/1.7.10-mcp908/src/minecraft/customskinloader/ModelManager0.java b/1.7.10-mcp908/src/minecraft/customskinloader/ModelManager0.java index 2d16905..de7823f 100644 --- a/1.7.10-mcp908/src/minecraft/customskinloader/ModelManager0.java +++ b/1.7.10-mcp908/src/minecraft/customskinloader/ModelManager0.java @@ -37,6 +37,8 @@ public class ModelManager0 { */ public static UserProfile toUserProfile(Map profile){ UserProfile userProfile=new UserProfile(); + if(profile==null) + return userProfile; MinecraftProfileTexture skin=(MinecraftProfileTexture)profile.get(Type.SKIN); userProfile.skinUrl= skin==null?null:skin.getUrl();//Avoid NullPointerException userProfile.model="default"; diff --git a/Common/customskinloader/CustomSkinLoader.java b/Common/customskinloader/CustomSkinLoader.java index 479e714..cfbb2d6 100644 --- a/Common/customskinloader/CustomSkinLoader.java +++ b/Common/customskinloader/CustomSkinLoader.java @@ -27,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.4 (2016.4.3) + * @version 13.5 (2016.4.3) */ public class CustomSkinLoader { - public static final String CustomSkinLoader_VERSION="13.4"; + public static final String CustomSkinLoader_VERSION="13.5"; 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"); @@ -58,7 +58,7 @@ public class CustomSkinLoader { } public static UserProfile loadProfile(String username,UserProfile defaultProfile){ logger.info("Loading "+username+"'s profile."); - if(profileCache.get(username)!=null){ + if(config.enableCache&&profileCache.get(username)!=null){ logger.info("Cached profile will be used."); UserProfile profile=profileCache.get(username); logger.info(profile.toString()); @@ -95,7 +95,7 @@ public class CustomSkinLoader { logger.info(username+"'s profile not found."); return defaultProfile; } - //For Skull (1.8.2 and Higher) + //For Skull public static Map loadProfileFromCache(String username) { if(profileCache.containsKey(username)){ UserProfile profile=profileCache.get(username); @@ -103,15 +103,6 @@ public class CustomSkinLoader { } return loadProfile(username,(Map)null); } - //For Skull (1.8.1 and Lower) - public static String loadSkinFromCache(String username) { - if(profileCache.containsKey(username)){ - UserProfile profile=profileCache.get(username); - return profile==null?null:profile.skinUrl; - } - UserProfile profile=loadProfile(username,(UserProfile)null); - return profile==null?null:profile.skinUrl; - } private static Logger initLogger() { Logger logger=new Logger(LOG_FILE); @@ -131,8 +122,9 @@ public class CustomSkinLoader { private static Config loadConfig0() { Config config=loadConfig(); - logger.info("Enable: "+config.enable); - logger.info("LoadList: "+(config.loadlist==null?0:config.loadlist.length)); + logger.info("Enable:"+config.enable+", EnableCache:"+config.enableCache+ + ", EnableSkull:"+config.enableSkull+", EnableTranSkin:"+config.enableTransparentSkin+ + ", LoadList:"+(config.loadlist==null?0:config.loadlist.length)); if(config.version==null||Float.parseFloat(config.version)