mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-26 12:43:01 +00:00
Support Dynamic Skull Texture Index
Local Texture Supported for Static Skull Fix network bug Try to use some forge
This commit is contained in:
1 parent
ea49e7489a
commit
a917e67871
9 files changed
+77
-24
No files matched your search
@@ -0,0 +1,8 @@
|
||||
package customskinloader.forge;
|
||||
|
||||
import cpw.mods.fml.common.Mod;
|
||||
|
||||
@Mod(modid = "CustomSkinLoader", version = "@MOD_FULL_VERSION@")
|
||||
public class BasicMod{
|
||||
|
||||
}
|
||||
@@ -38,8 +38,6 @@ public class CustomSkinLoader {
|
||||
//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.createUniSkinAPI("SkinMe","http://www.skinme.cc/uniskin/"),
|
||||
SkinSiteProfile.createCustomSkinAPI("McSkin","http://www.mcskin.cc/"),
|
||||
SkinSiteProfile.createElfSkin("ElfSkin"),
|
||||
SkinSiteProfile.createLegacy("LocalSkin","LocalSkin/skins/{USERNAME}.png","LocalSkin/capes/{USERNAME}.png","LocalSkin/elytras/{USERNAME}.png")};
|
||||
|
||||
public static final Gson GSON=new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
@@ -6,11 +6,28 @@ import java.io.FileOutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class Logger {
|
||||
private static final int LOWEST_DISPLAY_LEVEL=Level.INFO.intValue();
|
||||
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
public enum Level{
|
||||
DEBUG("DEBUG",false),
|
||||
INFO("INFO",true),
|
||||
WARNING("WARNING",true);
|
||||
|
||||
|
||||
String name;
|
||||
boolean display;
|
||||
Level(String name,boolean display){
|
||||
this.name=name;
|
||||
this.display=display;
|
||||
}
|
||||
public String getName(){
|
||||
return name;
|
||||
}
|
||||
public boolean display(){
|
||||
return display;
|
||||
}
|
||||
}
|
||||
private BufferedWriter writer=null;
|
||||
public Logger(){
|
||||
//Logger isn't created.
|
||||
@@ -40,12 +57,12 @@ public class Logger {
|
||||
}
|
||||
|
||||
public void log(Level level,String msg){
|
||||
if(level.intValue()<LOWEST_DISPLAY_LEVEL&&writer==null)
|
||||
if(!level.display()&&writer==null)
|
||||
return;
|
||||
StringBuilder sb=new StringBuilder();
|
||||
sb.append("[").append(Thread.currentThread().getName()).append(" ").append(level.getName()).append("] ");
|
||||
sb.append(msg);
|
||||
if(level.intValue()>=LOWEST_DISPLAY_LEVEL)
|
||||
if(level.display)
|
||||
System.out.println(sb.toString());
|
||||
if(writer==null)
|
||||
return;
|
||||
@@ -59,6 +76,9 @@ public class Logger {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void debug(String msg){
|
||||
log(Level.DEBUG,msg);
|
||||
}
|
||||
public void info(String msg){
|
||||
log(Level.INFO,msg);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package customskinloader.forge;
|
||||
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod(modid = "CustomSkinLoader", version = "@MOD_FULL_VERSION@")
|
||||
public class BasicMod{
|
||||
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package customskinloader.loader.jsonapi;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
@@ -20,7 +19,6 @@ import customskinloader.utils.MinecraftUtil;
|
||||
public class CustomSkinAPIPlus implements IJsonAPI {
|
||||
|
||||
private static String clientID=null;
|
||||
private static String deviceID=Preferences.systemRoot().node("CustomSkinAPIPlus").get("id", null);
|
||||
public CustomSkinAPIPlus(){
|
||||
File clientIDFile=new File(CustomSkinLoader.DATA_DIR,"CustomSkinAPIPlus-ClientID");
|
||||
|
||||
@@ -38,10 +36,6 @@ public class CustomSkinAPIPlus implements IJsonAPI {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if(StringUtils.isEmpty(deviceID)){
|
||||
deviceID=UUID.randomUUID().toString();
|
||||
Preferences.systemRoot().node("CustomSkinAPIPlus").put("id", deviceID);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String toJsonUrl(String root, String username) {
|
||||
@@ -70,7 +64,6 @@ public class CustomSkinAPIPlus implements IJsonAPI {
|
||||
public String modVersion;//mod version
|
||||
public String serverAddress;//ip:port
|
||||
public String clientID;//Minecraft Client ID
|
||||
public String deviceID;//Device ID
|
||||
public CustomSkinAPIPlusPayload(CustomSkinAPIPlusPrivacy privacy){
|
||||
if(privacy.gameVersion)
|
||||
gameVersion=MinecraftUtil.getMinecraftMainVersion();
|
||||
@@ -80,8 +73,6 @@ public class CustomSkinAPIPlus implements IJsonAPI {
|
||||
serverAddress=MinecraftUtil.isLanServer()?null:MinecraftUtil.getStandardServerAddress();
|
||||
if(privacy.clientID)
|
||||
clientID=CustomSkinAPIPlus.clientID;
|
||||
if(privacy.deviceID)
|
||||
deviceID=CustomSkinAPIPlus.deviceID;
|
||||
}
|
||||
}
|
||||
public static class CustomSkinAPIPlusPrivacy{
|
||||
@@ -89,6 +80,5 @@ public class CustomSkinAPIPlus implements IJsonAPI {
|
||||
public boolean modVersion=true;
|
||||
public boolean serverAddress=true;
|
||||
public boolean clientID=true;
|
||||
public boolean deviceID=true;
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import java.util.UUID;
|
||||
|
||||
import org.apache.commons.codec.Charsets;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@@ -32,6 +33,7 @@ import customskinloader.utils.HttpUtil0;
|
||||
public class DynamicSkullManager {
|
||||
public static class SkullTexture{
|
||||
public Map<Type,MinecraftProfileTexture> textures;
|
||||
public String index;//Index File
|
||||
public ArrayList<String> skins;
|
||||
public int interval;
|
||||
public boolean fromZero;
|
||||
@@ -61,7 +63,22 @@ public class DynamicSkullManager {
|
||||
staticTextures.put(profile, new HashMap());
|
||||
return;
|
||||
}
|
||||
staticTextures.put(profile, result.textures==null?new HashMap():result.textures);
|
||||
staticTextures.put(profile, (result.textures==null||!result.textures.containsKey(Type.SKIN))?new HashMap():parseTextures(result.textures));
|
||||
|
||||
if(StringUtils.isNotEmpty(result.index)){
|
||||
File indexFile=new File(CustomSkinLoader.DATA_DIR,result.index);
|
||||
try{
|
||||
String index=FileUtils.readFileToString(indexFile, Charsets.UTF_8);
|
||||
if(StringUtils.isNotEmpty(index)){
|
||||
ArrayList<String> skins=CustomSkinLoader.GSON.fromJson(index, ArrayList.class);
|
||||
if(skins!=null&&!skins.isEmpty())
|
||||
result.skins=skins;
|
||||
}
|
||||
}catch(Exception e){
|
||||
CustomSkinLoader.logger.warning("Exception occurs while parsing index file: "+e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
if(!CustomSkinLoader.config.enableDynamicSkull||result.skins==null||result.skins.isEmpty())
|
||||
return;
|
||||
|
||||
@@ -105,6 +122,19 @@ public class DynamicSkullManager {
|
||||
staticTextures.remove(profile);
|
||||
}
|
||||
|
||||
//Support local skin for skull
|
||||
public Map<Type, MinecraftProfileTexture> parseTextures(Map<Type, MinecraftProfileTexture> textures) {
|
||||
MinecraftProfileTexture skin=textures.get(Type.SKIN);
|
||||
String skinUrl=skin.getUrl();
|
||||
if(!HttpUtil0.isLocal(skinUrl))
|
||||
return textures;
|
||||
File skinFile=new File(CustomSkinLoader.DATA_DIR,skinUrl);
|
||||
if(!skinFile.isFile())
|
||||
return new HashMap();
|
||||
textures.put(Type.SKIN, ModelManager0.getProfileTexture(HttpTextureUtil.getLocalFakeUrl(skinUrl), null));
|
||||
return textures;
|
||||
}
|
||||
|
||||
public Map<Type,MinecraftProfileTexture> getTexture(final GameProfile profile){
|
||||
if(staticTextures.get(profile)!=null)
|
||||
return staticTextures.get(profile);
|
||||
|
||||
@@ -34,7 +34,7 @@ public class HttpTextureUtil {
|
||||
return info;
|
||||
}
|
||||
if(fakeUrl.startsWith(LOCAL_LEGACY_MARK)){
|
||||
fakeUrl=fakeUrl.replaceFirst(LOCAL_LEGACY_MARK, "");
|
||||
fakeUrl=fakeUrl.replace(LOCAL_LEGACY_MARK, "");
|
||||
String[] t=fakeUrl.split(",",2);
|
||||
if(t.length!=2)
|
||||
return info;
|
||||
@@ -43,13 +43,13 @@ public class HttpTextureUtil {
|
||||
return info;
|
||||
}
|
||||
if(fakeUrl.startsWith(LOCAL_MARK)){
|
||||
fakeUrl=fakeUrl.replaceFirst(LOCAL_MARK, "");
|
||||
fakeUrl=fakeUrl.replace(LOCAL_MARK, "");
|
||||
info.cacheFile=new File(CustomSkinLoader.DATA_DIR,fakeUrl);
|
||||
info.hash=FilenameUtils.getBaseName(fakeUrl);
|
||||
return info;
|
||||
}
|
||||
if(fakeUrl.startsWith(LEGACY_MARK)){
|
||||
fakeUrl=fakeUrl.replaceFirst(LEGACY_MARK, "");
|
||||
fakeUrl=fakeUrl.replace(LEGACY_MARK, "");
|
||||
info.url=fakeUrl;
|
||||
info.hash=DigestUtils.sha1Hex(info.url);;
|
||||
info.cacheFile=HttpTextureUtil.getCacheFile(info.hash);
|
||||
|
||||
@@ -16,7 +16,7 @@ Skin Load API Supported:
|
||||
- CustomSkinAPIPlus (Test Only)
|
||||
- [UniSkinAPI](https://github.com/RecursiveG/UniSkinServer/tree/master/doc)
|
||||
- Legacy
|
||||
- ElfSkin (Test Only)
|
||||
- ElfSkin (Self-made API, Test Only)
|
||||
|
||||
You can use this feature to customize your skin load list so as to load from any skin server you want.
|
||||
If you are the owner of skin server, you can use CustomSkinLoader to load skin from your server if one of the api has been actualized.
|
||||
@@ -52,8 +52,6 @@ The problem of rendering incorrect texture has been fixed.
|
||||
- [Blessing Skin](http://skin.prinzeugen.net/) (CustomSkinAPI)
|
||||
- [OneSkin](http://fleey.org/skin/) (CustomSkinAPI)
|
||||
- SkinMe (UniSkinAPI)
|
||||
- [McSkin](http://www.mcskin.cc/) (CustomSkinAPI)
|
||||
- [ElfSkin](http://www.mcelf.com/s/mcskin/) (Self-made API)
|
||||
- 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).
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ jar {
|
||||
attributes 'TweakAuthor' : 'xfl03,JLChnToZ'
|
||||
attributes 'TweakVersion' : version
|
||||
attributes 'TweakOrder' : '-10'
|
||||
attributes 'FMLCorePluginContainsFMLMod' : true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user