Files
MCCustomSkinLoader/Common/customskinloader/loader/LegacyLoader.java
T
Alexander Xia 7654dc583d Added custom useragent
Faster mod loading
Backup broken json
Added a new skin site
2016-07-04 14:10:44 +08:00

35 lines
1.1 KiB
Java

package customskinloader.loader;
import customskinloader.CustomSkinLoader;
import customskinloader.UserProfile;
import customskinloader.config.SkinSiteProfile;
import customskinloader.utils.HttpUtil0;
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("")){
String skin=HttpUtil0.getRealUrl(ssp.skin.replaceAll(USERNAME_REGEX, username),ssp.userAgent);
if(skin!=null&&!skin.equals("")){
profile.skinUrl=skin;
profile.model=(ssp.model==null?"default":ssp.model);
}
}
if(ssp.cape!=null && !ssp.cape.equals("")){
String cape=HttpUtil0.getRealUrl(ssp.cape.replaceAll(USERNAME_REGEX, username),ssp.userAgent);
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;
}
}
}