mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-18 17:19:15 +00:00
Add: support WynntilsAPI cape
This commit is contained in:
1 parent
84072c62f3
commit
dd4b706827
14 files changed
+403
-158
No files matched your search
@@ -6,7 +6,6 @@ import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.config.SkinSiteProfile;
|
||||
import customskinloader.loader.JsonAPILoader;
|
||||
import customskinloader.plugin.ICustomSkinLoaderPlugin;
|
||||
import customskinloader.profile.ModelManager0;
|
||||
@@ -17,17 +16,45 @@ import org.apache.commons.lang3.StringUtils;
|
||||
public class CustomSkinAPI implements JsonAPILoader.IJsonAPI {
|
||||
|
||||
public static class LittleSkin extends JsonAPILoader.DefaultProfile {
|
||||
public LittleSkin(JsonAPILoader loader) { super(loader); }
|
||||
@Override public String getName() { return "LittleSkin"; }
|
||||
@Override public int getPriority() { return 200; }
|
||||
@Override public String getRoot() { return "https://littleskin.cn/csl/"; }
|
||||
public LittleSkin(JsonAPILoader loader) {
|
||||
super(loader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "LittleSkin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 200;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRoot() {
|
||||
return "https://littleskin.cn/csl/";
|
||||
}
|
||||
}
|
||||
|
||||
public static class BlessingSkin extends JsonAPILoader.DefaultProfile {
|
||||
public BlessingSkin(JsonAPILoader loader) { super(loader); }
|
||||
@Override public String getName() { return "BlessingSkin"; }
|
||||
@Override public int getPriority() { return 300; }
|
||||
@Override public String getRoot() { return "https://skin.prinzeugen.net/"; }
|
||||
public BlessingSkin(JsonAPILoader loader) {
|
||||
super(loader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "BlessingSkin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return 300;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRoot() {
|
||||
return "https://skin.prinzeugen.net/";
|
||||
}
|
||||
}
|
||||
|
||||
// // OneSkin has been removed temporarily
|
||||
@@ -38,8 +65,8 @@ public class CustomSkinAPI implements JsonAPILoader.IJsonAPI {
|
||||
// @Override public String getRoot() { return "http://fleey.cn/skin/skin_user/skin_json.php/"; }
|
||||
// }
|
||||
|
||||
private static final String TEXTURES="textures/";
|
||||
private static final String SUFFIX=".json";
|
||||
private static final String TEXTURES = "textures/";
|
||||
private static final String SUFFIX = ".json";
|
||||
|
||||
@Override
|
||||
public List<ICustomSkinLoaderPlugin.IDefaultProfile> getDefaultProfiles(JsonAPILoader loader) {
|
||||
@@ -53,65 +80,63 @@ public class CustomSkinAPI implements JsonAPILoader.IJsonAPI {
|
||||
|
||||
@Override
|
||||
public UserProfile toUserProfile(String root, String json, boolean local) {
|
||||
CustomSkinAPIProfile profile=CustomSkinLoader.GSON.fromJson(json, CustomSkinAPIProfile.class);
|
||||
UserProfile p=new UserProfile();
|
||||
|
||||
if(StringUtils.isNotBlank(profile.skin)){
|
||||
p.skinUrl=root+TEXTURES+profile.skin;
|
||||
if(local)
|
||||
p.skinUrl=HttpTextureUtil.getLocalFakeUrl(p.skinUrl);
|
||||
CustomSkinAPIProfile profile = CustomSkinLoader.GSON.fromJson(json, CustomSkinAPIProfile.class);
|
||||
UserProfile p = new UserProfile();
|
||||
|
||||
if (StringUtils.isNotBlank(profile.skin)) {
|
||||
p.skinUrl = root + TEXTURES + profile.skin;
|
||||
if (local)
|
||||
p.skinUrl = HttpTextureUtil.getLocalFakeUrl(p.skinUrl);
|
||||
}
|
||||
if(StringUtils.isNotBlank(profile.cape)){
|
||||
p.capeUrl=root+TEXTURES+profile.cape;
|
||||
if(local)
|
||||
p.capeUrl=HttpTextureUtil.getLocalFakeUrl(p.capeUrl);
|
||||
if (StringUtils.isNotBlank(profile.cape)) {
|
||||
p.capeUrl = root + TEXTURES + profile.cape;
|
||||
if (local)
|
||||
p.capeUrl = HttpTextureUtil.getLocalFakeUrl(p.capeUrl);
|
||||
}
|
||||
if(StringUtils.isNotBlank(profile.elytra)){
|
||||
p.elytraUrl=root+TEXTURES+profile.elytra;
|
||||
if(local)
|
||||
p.elytraUrl=HttpTextureUtil.getLocalFakeUrl(p.elytraUrl);
|
||||
if (StringUtils.isNotBlank(profile.elytra)) {
|
||||
p.elytraUrl = root + TEXTURES + profile.elytra;
|
||||
if (local)
|
||||
p.elytraUrl = HttpTextureUtil.getLocalFakeUrl(p.elytraUrl);
|
||||
}
|
||||
|
||||
Map<String,String> textures=new LinkedHashMap<>();
|
||||
if(profile.skins!=null)
|
||||
|
||||
Map<String, String> textures = new LinkedHashMap<>();
|
||||
if (profile.skins != null)
|
||||
textures.putAll(profile.skins);
|
||||
if(profile.textures!=null)
|
||||
if (profile.textures != null)
|
||||
textures.putAll(profile.textures);
|
||||
if(textures.isEmpty())
|
||||
if (textures.isEmpty())
|
||||
return p;
|
||||
|
||||
boolean hasSkin=false;
|
||||
for(String model:textures.keySet()){
|
||||
ModelManager0.Model enumModel=ModelManager0.getEnumModel(model);
|
||||
if(enumModel==null||StringUtils.isEmpty(textures.get(model)))
|
||||
|
||||
boolean hasSkin = false;
|
||||
for (String model : textures.keySet()) {
|
||||
ModelManager0.Model enumModel = ModelManager0.getEnumModel(model);
|
||||
if (enumModel == null || StringUtils.isEmpty(textures.get(model)))
|
||||
continue;
|
||||
if(ModelManager0.isSkin(enumModel))
|
||||
if(hasSkin)
|
||||
if (ModelManager0.isSkin(enumModel))
|
||||
if (hasSkin)
|
||||
continue;
|
||||
else
|
||||
hasSkin=true;
|
||||
String url=root+TEXTURES+textures.get(model);
|
||||
if(local)
|
||||
url=HttpTextureUtil.getLocalFakeUrl(url);
|
||||
hasSkin = true;
|
||||
String url = root + TEXTURES + textures.get(model);
|
||||
if (local)
|
||||
url = HttpTextureUtil.getLocalFakeUrl(url);
|
||||
p.put(enumModel, url);
|
||||
}
|
||||
|
||||
|
||||
return p;
|
||||
}
|
||||
private static class CustomSkinAPIProfile{
|
||||
|
||||
private static class CustomSkinAPIProfile {
|
||||
public String username;
|
||||
public LinkedHashMap<String,String> textures;
|
||||
|
||||
public LinkedHashMap<String,String> skins;
|
||||
|
||||
public LinkedHashMap<String, String> textures;
|
||||
|
||||
public LinkedHashMap<String, String> skins;
|
||||
|
||||
public String skin;
|
||||
public String cape;
|
||||
public String elytra;
|
||||
}
|
||||
@Override
|
||||
public String getPayload(SkinSiteProfile ssp) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "CustomSkinAPI";
|
||||
|
||||
Reference in new issue
Block a user