mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-28 12:26:05 +00:00
Remove some useless code
This commit is contained in:
1 parent
1d88a98040
commit
8bccab4f0b
8 files changed
+64
-120
No files matched your search
@@ -12,59 +12,40 @@ import customskinloader.utils.HttpUtil0;
|
||||
|
||||
public class LegacyLoader implements IProfileLoader {
|
||||
public static final String USERNAME_REGEX="\\{USERNAME\\}";
|
||||
|
||||
@Override
|
||||
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception {
|
||||
String username=gameProfile.getName();
|
||||
UserProfile profile=new UserProfile();
|
||||
if(ssp.skin!=null && !ssp.skin.equals("")){
|
||||
String skin=HttpUtil0.getFakeUrl(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.getFakeUrl(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;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public UserProfile loadLocalProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception {
|
||||
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile, boolean local) throws Exception {
|
||||
String username=gameProfile.getName();
|
||||
UserProfile profile=new UserProfile();
|
||||
if(ssp.skin!=null && !ssp.skin.equals("")){
|
||||
String skin=ssp.skin.replaceAll(USERNAME_REGEX, username);
|
||||
if(skin!=null&&!skin.equals("")){
|
||||
if(local){
|
||||
File skinFile=new File(CustomSkinLoader.DATA_DIR,skin);
|
||||
if(skinFile.exists()&&skinFile.isFile()){
|
||||
if(skinFile.exists()&&skinFile.isFile())
|
||||
profile.skinUrl=HttpTextureUtil.getLocalLegacyFakeUrl(skin, HttpTextureUtil.getHash(skin, skinFile.length(), skinFile.lastModified()));
|
||||
profile.model=(ssp.model==null?"default":ssp.model);
|
||||
}
|
||||
}else{
|
||||
String fakeSkinUrl=HttpUtil0.getFakeUrl(skin,ssp.userAgent);
|
||||
if(fakeSkinUrl!=null&&!fakeSkinUrl.equals(""))
|
||||
profile.skinUrl=fakeSkinUrl;
|
||||
}
|
||||
profile.model=profile.hasSkinUrl()?ssp.model:null;
|
||||
}
|
||||
if(ssp.cape!=null && !ssp.cape.equals("")){
|
||||
String cape=ssp.cape.replaceAll(USERNAME_REGEX, username);
|
||||
if(cape!=null&&!cape.equals("")){
|
||||
if(local){
|
||||
File capeFile=new File(CustomSkinLoader.DATA_DIR,cape);
|
||||
if(capeFile.exists()&&capeFile.isFile()){
|
||||
if(capeFile.exists()&&capeFile.isFile())
|
||||
profile.capeUrl=HttpTextureUtil.getLocalLegacyFakeUrl(cape, HttpTextureUtil.getHash(cape, capeFile.length(), capeFile.lastModified()));
|
||||
}
|
||||
}else{
|
||||
String fakeCapeUrl=HttpUtil0.getFakeUrl(cape,ssp.userAgent);
|
||||
if(fakeCapeUrl!=null&&fakeCapeUrl.equals(""))
|
||||
profile.capeUrl=fakeCapeUrl;
|
||||
}
|
||||
}
|
||||
if(profile.isEmpty()){
|
||||
CustomSkinLoader.logger.info("Both skin and cape not found.");
|
||||
return null;
|
||||
}else{
|
||||
return profile;
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user