mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-12 03:47:33 +00:00
* Enhance ICustomSkinLoaderPlugin. * Support auto update config file per snapshot. Fix crash with forge 1.14.2 ~ 1.15.2. * ElyByAPI should check root now. * Remove unnecessary packages, add some deprecated loaders. * Reformat imports. * Move forge stuffs to another commit. * Fix config updating incorrectly.
85 lines
2.8 KiB
Java
85 lines
2.8 KiB
Java
package customskinloader.loader.jsonapi;
|
|
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import customskinloader.CustomSkinLoader;
|
|
import customskinloader.config.SkinSiteProfile;
|
|
import customskinloader.loader.JsonAPILoader;
|
|
import customskinloader.profile.ModelManager0;
|
|
import customskinloader.profile.UserProfile;
|
|
import customskinloader.utils.HttpTextureUtil;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
public abstract class UniSkinAPI implements JsonAPILoader.IJsonAPI {
|
|
|
|
public static class SkinMe extends UniSkinAPI {
|
|
@Override public String getLoaderName() { return "SkinMe"; }
|
|
@Override public String getRoot() { return "http://www.skinme.cc/uniskin/"; }
|
|
}
|
|
|
|
private static final String TEXTURES="textures/";
|
|
private static final String SUFFIX=".json";
|
|
|
|
@Override
|
|
public String toJsonUrl(String root, String username) {
|
|
return root + username + SUFFIX;
|
|
}
|
|
|
|
@Override
|
|
public UserProfile toUserProfile(String root, String json, boolean local) {
|
|
UniSkinAPIProfile profile=CustomSkinLoader.GSON.fromJson(json, UniSkinAPIProfile.class);
|
|
UserProfile p=new UserProfile();
|
|
|
|
if(StringUtils.isNotBlank(profile.cape)){
|
|
p.capeUrl=root+TEXTURES+profile.cape;
|
|
if(local)
|
|
p.capeUrl=HttpTextureUtil.getLocalFakeUrl(p.capeUrl);
|
|
}
|
|
|
|
if(profile.skins==null||profile.skins.isEmpty())
|
|
return p;
|
|
if(profile.model_preference==null||profile.model_preference.isEmpty())
|
|
return p;
|
|
|
|
boolean hasSkin=false;
|
|
for(String model:profile.model_preference){
|
|
ModelManager0.Model enumModel=ModelManager0.getEnumModel(model);
|
|
if(enumModel==null||StringUtils.isEmpty(profile.skins.get(model)))
|
|
continue;
|
|
if(ModelManager0.isSkin(enumModel))
|
|
if(hasSkin)
|
|
continue;
|
|
else
|
|
hasSkin=true;
|
|
String url=root+TEXTURES+profile.skins.get(model);
|
|
if(local)
|
|
url=HttpTextureUtil.getLocalFakeUrl(url);
|
|
p.put(enumModel, url);
|
|
}
|
|
|
|
return p;
|
|
}
|
|
/**
|
|
* Json profile for UniSkinAPI
|
|
* Source Code: https://github.com/RecursiveG/UniSkinMod/blob/master/src/main/java/org/devinprogress/uniskinmod/UniSkinApiProfile.java#L18-L22
|
|
* @author RecursiveG
|
|
*/
|
|
private class UniSkinAPIProfile{
|
|
public String player_name;
|
|
public long last_update;
|
|
public List<String> model_preference;
|
|
public Map<String,String> skins;
|
|
|
|
public String cape;
|
|
}
|
|
@Override
|
|
public String getPayload(SkinSiteProfile ssp) {
|
|
return null;
|
|
}
|
|
@Override
|
|
public String getName() {
|
|
return "UniSkinAPI";
|
|
}
|
|
}
|