mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-12 21:17:38 +00:00
Load Elytra Standalone
This commit is contained in:
1 parent
5d366d1d8c
commit
9a85d18f22
9 files changed
+189
-100
No files matched your search
@@ -1,11 +1,15 @@
|
||||
package customskinloader.loader.jsonapi;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.loader.JsonAPILoader.IJsonAPI;
|
||||
import customskinloader.profile.ModelManager0;
|
||||
import customskinloader.profile.ModelManager0.Model;
|
||||
import customskinloader.profile.UserProfile;
|
||||
import customskinloader.utils.HttpTextureUtil;
|
||||
|
||||
@@ -22,39 +26,50 @@ public class CustomSkinAPI implements IJsonAPI {
|
||||
public UserProfile toUserProfile(String root, String json, boolean local) {
|
||||
CustomSkinAPIProfile profile=CustomSkinLoader.GSON.fromJson(json, CustomSkinAPIProfile.class);
|
||||
UserProfile p=new UserProfile();
|
||||
if(profile.skins!=null && !profile.skins.isEmpty()){
|
||||
Set<String> keys=profile.skins.keySet();
|
||||
for(String s:keys){
|
||||
//System.out.println(s+" "+ModelManager0.checkModel(s));
|
||||
if(ModelManager0.checkModel(s)){
|
||||
if(profile.skins.get(s)==null||profile.skins.get(s).equals(""))
|
||||
continue;
|
||||
p.skinUrl=root+TEXTURES+profile.skins.get(s);
|
||||
p.model=s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(p.skinUrl==null){
|
||||
p.skinUrl=root+TEXTURES+profile.skins.get(keys.toArray()[0]);
|
||||
p.model="default";
|
||||
}
|
||||
}else if(profile.skin!=null && !profile.skin.equals("")){
|
||||
|
||||
if(StringUtils.isNotBlank(profile.skin)){
|
||||
p.skinUrl=root+TEXTURES+profile.skin;
|
||||
if(local)
|
||||
p.skinUrl=HttpTextureUtil.getLocalFakeUrl(p.skinUrl);
|
||||
}
|
||||
if(profile.cape!=null && !profile.cape.equals("")){
|
||||
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);
|
||||
}
|
||||
|
||||
Map<String,String> textures=new LinkedHashMap<String,String>();
|
||||
if(profile.skins!=null)
|
||||
textures.putAll(profile.skins);
|
||||
if(profile.textures!=null)
|
||||
textures.putAll(profile.textures);
|
||||
if(textures.isEmpty())
|
||||
return p;
|
||||
for(String model:textures.keySet()){
|
||||
Model enumModel=ModelManager0.getEnumModel(model);
|
||||
if(enumModel==null||StringUtils.isEmpty(textures.get(model)))
|
||||
continue;
|
||||
String url=root+TEXTURES+textures.get(model);
|
||||
if(local)
|
||||
url=HttpTextureUtil.getLocalFakeUrl(url);
|
||||
p.put(enumModel, url);
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
private class CustomSkinAPIProfile{
|
||||
public String username;
|
||||
public Map<String,String> textures;
|
||||
|
||||
public Map<String,String> skins;
|
||||
public String skin;
|
||||
public String cape;
|
||||
public String elytra;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
|
||||
Reference in new issue
Block a user