diff --git a/Common/source/customskinloader/CustomSkinLoader.java b/Common/source/customskinloader/CustomSkinLoader.java index c534cc4..c7334fb 100644 --- a/Common/source/customskinloader/CustomSkinLoader.java +++ b/Common/source/customskinloader/CustomSkinLoader.java @@ -39,6 +39,7 @@ public class CustomSkinLoader { //SkinSiteProfile.createCustomSkinAPI("OneSkin","http://fleey.cn/skin/skin_user/skin_json.php/"), //Minecrack could not load skin correctly //SkinSiteProfile.creatLegacy("Minecrack","http://minecrack.fr.nf/mc/skinsminecrackd/{USERNAME}.png","http://minecrack.fr.nf/mc/cloaksminecrackd/{USERNAME}.png",null), + SkinSiteProfile.createElyByAPI("ElyBy"), SkinSiteProfile.createUniSkinAPI("SkinMe","http://www.skinme.cc/uniskin/"), SkinSiteProfile.createLegacy("LocalSkin","LocalSkin/skins/{USERNAME}.png","LocalSkin/capes/{USERNAME}.png","LocalSkin/elytras/{USERNAME}.png")}; diff --git a/Common/source/customskinloader/config/SkinSiteProfile.java b/Common/source/customskinloader/config/SkinSiteProfile.java index 528bfb4..f39ef53 100644 --- a/Common/source/customskinloader/config/SkinSiteProfile.java +++ b/Common/source/customskinloader/config/SkinSiteProfile.java @@ -55,4 +55,11 @@ public class SkinSiteProfile { ssp.elytra=elytra; return ssp; } + + public static SkinSiteProfile createElyByAPI(String name) { + SkinSiteProfile ssp = new SkinSiteProfile(); + ssp.name = name; + ssp.type = "ElyByAPI"; + return ssp; + } } diff --git a/Common/source/customskinloader/utils/JavaUtil.java b/Common/source/customskinloader/utils/JavaUtil.java new file mode 100644 index 0000000..6e2f5c6 --- /dev/null +++ b/Common/source/customskinloader/utils/JavaUtil.java @@ -0,0 +1,34 @@ +package customskinloader.utils; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.LinkedList; + +public class JavaUtil { + public static URL[] getClasspath() { + if (JavaUtil.class.getClassLoader() instanceof URLClassLoader) { + //Java 8- + //Use URLClassLoader Directly + URLClassLoader ucl = (URLClassLoader) JavaUtil.class.getClassLoader(); + return ucl.getURLs(); + } else { + //Java 9+ + //It uses APPClassLoader instead of URLClassLoader + //Get Classpath from properties and parse it to URL array + String classpath = System.getProperty("java.class.path"); + String[] elements = classpath.split(File.pathSeparator); + if (elements.length == 0) + return new URL[0]; + LinkedList urls = new LinkedList(); + for (String ele : elements) { + try { + urls.add(new URL(ele)); + } catch (Exception ignored) { + } + } + return (URL[]) urls.toArray(); + } + } +} diff --git a/Common/source/customskinloader/utils/MinecraftUtil.java b/Common/source/customskinloader/utils/MinecraftUtil.java index fe6130f..8dc9985 100644 --- a/Common/source/customskinloader/utils/MinecraftUtil.java +++ b/Common/source/customskinloader/utils/MinecraftUtil.java @@ -2,7 +2,6 @@ package customskinloader.utils; import java.io.File; import java.net.URL; -import java.net.URLClassLoader; import java.net.URLDecoder; import java.util.ArrayList; import java.util.regex.Matcher; @@ -85,8 +84,7 @@ public class MinecraftUtil { private final static Pattern MINECRAFT_CORE_FILE_PATTERN = Pattern.compile("^(.*?)/versions/([^\\/\\\\]*?)/([^\\/\\\\]*?).jar$"); private static void testProbe(){ minecraftVersion.clear(); - URLClassLoader ucl = (URLClassLoader) MinecraftUtil.class.getClassLoader(); - URL urls[] = ucl.getURLs(); + URL urls[] = JavaUtil.getClasspath(); for(URL url:urls){ Matcher m = null; try{ diff --git a/Forge/build.gradle b/Forge/build.gradle index 140b440..73c0f26 100644 --- a/Forge/build.gradle +++ b/Forge/build.gradle @@ -1,5 +1,6 @@ buildscript { repositories { + mavenCentral() jcenter() maven { name = "forge" diff --git a/README.md b/README.md index 8904e1e..6e2a015 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ The problem of rendering incorrect texture has been fixed. - [Mojang](http://www.minecraft.net/) (Mojang API) - [LittleSkin](https://littleskin.cn/) (CustomSkinAPI) - [Blessing Skin](http://skin.prinzeugen.net/) (CustomSkinAPI) +- [ElyBy](http://docs.ely.by/) (ElyByAPI) - SkinMe (UniSkinAPI) - LocalSkin (Legacy) If you want to apply to add other skin server to default list, please go to [issue](https://github.com/JLChnToZ/MCCustomSkinLoader/issues). diff --git a/Vanilla/customskinloader/tweaker/ClassTransformer.java b/Vanilla/customskinloader/tweaker/ClassTransformer.java index 3b3e71f..8c7baf3 100644 --- a/Vanilla/customskinloader/tweaker/ClassTransformer.java +++ b/Vanilla/customskinloader/tweaker/ClassTransformer.java @@ -4,12 +4,12 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URL; -import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Enumeration; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; +import customskinloader.utils.JavaUtil; import org.apache.commons.io.IOUtils; import customskinloader.utils.MinecraftUtil; @@ -23,8 +23,7 @@ public class ClassTransformer implements IClassTransformer { public ClassTransformer() { ModSystemTweaker.logger.info("ClassTransformer Begin"); try { - URLClassLoader ucl = (URLClassLoader)this.getClass().getClassLoader(); - URL urls[] = ucl.getURLs(); + URL urls[] = JavaUtil.getClasspath(); for (URL url : urls) { if(MinecraftUtil.isCoreFile(url)){ ModSystemTweaker.logger.debug(url.toString()+" : SKIP (core file)."); diff --git a/build.gradle b/build.gradle index 8b1a43c..2d3388f 100644 --- a/build.gradle +++ b/build.gradle @@ -9,6 +9,7 @@ configFile.withReader { } buildscript { repositories { + mavenCentral() jcenter() maven { name = "forge" diff --git a/common.gradle b/common.gradle index e0aa08e..117e774 100644 --- a/common.gradle +++ b/common.gradle @@ -1,5 +1,6 @@ buildscript { repositories { + mavenCentral() jcenter() maven { name = "forge"