Enhanced default skin loaders. (#157)

* 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.
This commit is contained in:
ZekerZhayard authored and GitHub committed 2021-04-24 10:33:18 +08:00
1 parent c84f506af1
commit 6c9494970f
17 files changed
+286 -218

No files matched your search

@@ -1,40 +1,30 @@
package customskinloader.loader.jsonapi;
import java.util.Map;
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 abstract class ElyByAPI implements JsonAPILoader.IJsonAPI {
public static class ElyBy extends ElyByAPI {
@Override public String getLoaderName() { return "ElyBy"; }
@Override public String getRoot() { return "http://skinsystem.ely.by/textures/"; }
}
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();
return root + username;
}
@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;
}
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> result = new Gson().fromJson(json, new TypeToken<Map<MinecraftProfileTexture.Type, MinecraftProfileTexture>>() { }.getType());
return ModelManager0.toUserProfile(result);
}