mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-22 09:39:45 +00:00
Add ElyByAPI
This commit is contained in:
1 parent
6ffdf2aafb
commit
a36eca2a53
7 files changed
+68
-11
No files matched your search
@@ -26,7 +26,7 @@ public class Config {
|
||||
public boolean forceLoadAllTextures=false;
|
||||
|
||||
//Cache
|
||||
public int cacheExpiry=20;
|
||||
public int cacheExpiry=30;
|
||||
public boolean enableUpdateSkull=false;
|
||||
public boolean enableLocalProfileCache=false;
|
||||
public boolean enableCacheAutoClean=false;
|
||||
|
||||
@@ -30,7 +30,10 @@ public class JsonAPILoader implements ProfileLoader.IProfileLoader {
|
||||
public String msg;
|
||||
}
|
||||
public enum Type{
|
||||
CustomSkinAPI(new CustomSkinAPI()),CustomSkinAPIPlus(new CustomSkinAPIPlus()),UniSkinAPI(new UniSkinAPI());
|
||||
CustomSkinAPI(new CustomSkinAPI()),
|
||||
CustomSkinAPIPlus(new CustomSkinAPIPlus()),
|
||||
UniSkinAPI(new UniSkinAPI()),
|
||||
ElyByAPI(new ElyByAPI());
|
||||
public IJsonAPI jsonAPI;
|
||||
Type(IJsonAPI jsonAPI){
|
||||
this.jsonAPI=jsonAPI;
|
||||
@@ -45,11 +48,11 @@ public class JsonAPILoader implements ProfileLoader.IProfileLoader {
|
||||
@Override
|
||||
public UserProfile loadProfile(SkinSiteProfile ssp, GameProfile gameProfile) throws Exception {
|
||||
String username=gameProfile.getName();
|
||||
boolean local=HttpUtil0.isLocal(ssp.root);
|
||||
if(ssp.root==null||ssp.root.equals("")){
|
||||
if(StringUtils.isEmpty(ssp.root) && type!=Type.ElyByAPI){
|
||||
CustomSkinLoader.logger.info("Root not defined.");
|
||||
return null;
|
||||
}
|
||||
boolean local = HttpUtil0.isLocal(ssp.root);
|
||||
String jsonUrl=type.jsonAPI.toJsonUrl(ssp.root, username);
|
||||
String json;
|
||||
if(local){
|
||||
|
||||
@@ -12,8 +12,9 @@ public class ProfileLoader {
|
||||
new MojangAPILoader(),
|
||||
new JsonAPILoader(JsonAPILoader.Type.CustomSkinAPI),
|
||||
new JsonAPILoader(JsonAPILoader.Type.CustomSkinAPIPlus),
|
||||
new LegacyLoader(),
|
||||
new JsonAPILoader(JsonAPILoader.Type.UniSkinAPI)};
|
||||
new JsonAPILoader(JsonAPILoader.Type.UniSkinAPI),
|
||||
new JsonAPILoader(JsonAPILoader.Type.ElyByAPI),
|
||||
new LegacyLoader()};
|
||||
|
||||
public static final HashMap<String,IProfileLoader> LOADERS=initLoaders();
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package customskinloader.loader.jsonapi;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture.Type;
|
||||
import customskinloader.config.SkinSiteProfile;
|
||||
import customskinloader.loader.JsonAPILoader;
|
||||
import customskinloader.profile.ModelManager0;
|
||||
import customskinloader.profile.UserProfile;
|
||||
import customskinloader.utils.MinecraftUtil;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
public class ElyByAPI implements JsonAPILoader.IJsonAPI {
|
||||
@Override
|
||||
public String toJsonUrl(String root, String username) {
|
||||
return "http://skinsystem.ely.by/textures/" + username + "?version=2&minecraft_version=" + MinecraftUtil.getMinecraftMainVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserProfile toUserProfile(String root, String json, boolean local) {
|
||||
Map<Type, MinecraftProfileTexture> result = new Gson().fromJson(json, new TypeToken<Map<Type, MinecraftProfileTexture>>() {
|
||||
}.getType());
|
||||
if (!result.containsKey(Type.SKIN))
|
||||
return null;
|
||||
|
||||
//Check URL
|
||||
try {
|
||||
URI uri = new URI(result.get(Type.SKIN).getUrl());
|
||||
if (!uri.getHost().endsWith("ely.by"))
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return ModelManager0.toUserProfile(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPayload(SkinSiteProfile ssp) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "ElyByAPI";
|
||||
}
|
||||
}
|
||||
@@ -67,17 +67,17 @@ public class ModelManager0 {
|
||||
* @return profile - UserProfile instance
|
||||
* @since 13.1
|
||||
*/
|
||||
public static UserProfile toUserProfile(Map profile){
|
||||
public static UserProfile toUserProfile(Map<Type, MinecraftProfileTexture> profile){
|
||||
UserProfile userProfile=new UserProfile();
|
||||
if(profile==null)
|
||||
return userProfile;
|
||||
MinecraftProfileTexture skin=(MinecraftProfileTexture)profile.get(Type.SKIN);
|
||||
MinecraftProfileTexture skin = profile.get(Type.SKIN);
|
||||
userProfile.skinUrl= skin==null?null:skin.getUrl();//Avoid NullPointerException
|
||||
userProfile.model= skin==null?null:skin.getMetadata("model");
|
||||
if(StringUtils.isEmpty(userProfile.model))
|
||||
userProfile.model="default";
|
||||
|
||||
MinecraftProfileTexture cape=(MinecraftProfileTexture)profile.get(Type.CAPE);
|
||||
MinecraftProfileTexture cape = profile.get(Type.CAPE);
|
||||
userProfile.capeUrl= cape==null?null:cape.getUrl();
|
||||
return userProfile;
|
||||
}
|
||||
|
||||
@@ -91,8 +91,10 @@ public class UserProfile {
|
||||
public void mix(UserProfile profile){
|
||||
if(profile==null)
|
||||
return;
|
||||
if(StringUtils.isEmpty(this.skinUrl))
|
||||
this.skinUrl=profile.skinUrl;
|
||||
if(StringUtils.isEmpty(this.skinUrl)) {
|
||||
this.skinUrl = profile.skinUrl;
|
||||
this.model = profile.model;
|
||||
}
|
||||
if(StringUtils.isEmpty(this.capeUrl))
|
||||
this.capeUrl=profile.capeUrl;
|
||||
if(StringUtils.isEmpty(this.elytraUrl))
|
||||
|
||||
@@ -14,6 +14,7 @@ Skin Load API Supported:
|
||||
- [CustomSkinAPI](https://github.com/xfl03/CustomSkinLoaderAPI/tree/master/CustomSkinAPI)
|
||||
- CustomSkinAPIPlus (Test Only)
|
||||
- [UniSkinAPI](https://github.com/RecursiveG/UniSkinServer/tree/master/doc)
|
||||
- [ElfByAPI](http://docs.ely.by/api.html)
|
||||
- Legacy
|
||||
|
||||
You can use this feature to customize your skin load list so as to load from any skin server you want.
|
||||
|
||||
Reference in new issue
Block a user