Files
MCCustomSkinLoader/Common/customskinloader/loader/LegacyLoader.java
T

34 lines
1.0 KiB
Java
Raw Normal View History

2016-02-27 15:22:35 +08:00
package customskinloader.loader;
import customskinloader.CustomSkinLoader;
import customskinloader.UserProfile;
import customskinloader.config.SkinSiteProfile;
2016-02-27 16:37:05 +08:00
import customskinloader.utils.HttpUtil0;
2016-02-27 15:22:35 +08:00
public class LegacyLoader implements IProfileLoader {
public static final String USERNAME_REGEX="\\{USERNAME\\}";
@Override
public UserProfile loadProfile(SkinSiteProfile ssp, String username) throws Exception {
UserProfile profile=new UserProfile();
if(ssp.skin!=null && !ssp.skin.equals("")){
2016-02-27 16:37:05 +08:00
String skin=HttpUtil0.getRealUrl(ssp.skin.replaceAll(USERNAME_REGEX, username));
2016-02-27 15:22:35 +08:00
if(skin!=null&&!skin.equals("")){
profile.skinUrl=skin;
2016-04-03 13:01:06 +08:00
profile.model=(ssp.model==null?"default":ssp.model);
2016-02-27 15:22:35 +08:00
}
}
if(ssp.cape!=null && !ssp.cape.equals("")){
2016-02-27 16:37:05 +08:00
String cape=HttpUtil0.getRealUrl(ssp.cape.replaceAll(USERNAME_REGEX, username));
2016-02-27 15:22:35 +08:00
if(cape!=null&&!cape.equals("")){
profile.capeUrl=cape;
}
}
if(profile.isEmpty()){
CustomSkinLoader.logger.info("Both skin and cape not found.");
return null;
}else{
return profile;
}
}
}