mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-21 09:12:19 +00:00
Added Extra List
This commit is contained in:
1 parent
10c0536dbe
commit
37960965b4
10 files changed
+169
-91
No files matched your search
@@ -1,5 +0,0 @@
|
||||
Manifest-Version: 1.0
|
||||
TweakClass: customskinloader.tweaker.ModSystemTweaker
|
||||
TweakName: CustomSkinLoader
|
||||
TweakAuthor: xfl03,JLChnToZ
|
||||
TweakOrder: -10
|
||||
@@ -46,11 +46,10 @@ public class CustomSkinLoader {
|
||||
SkinSiteProfile.createUniSkinAPI("SkinMe","http://www.skinme.cc/uniskin/"),
|
||||
SkinSiteProfile.createCustomSkinAPI("McSkin","http://www.mcskin.cc/"),
|
||||
SkinSiteProfile.createLegacy("LocalSkin", true, "LocalSkin/skins/{USERNAME}.png", "LocalSkin/capes/{USERNAME}.png")};
|
||||
public static final HashMap<String,IProfileLoader> LOADERS=initLoaders();
|
||||
|
||||
public static final Gson GSON=new GsonBuilder().setPrettyPrinting().create();
|
||||
public static final Logger logger=initLogger();
|
||||
public static final Config config=loadConfig0();
|
||||
public static final Config config=Config.loadConfig0();
|
||||
|
||||
private static final ProfileCache profileCache=new ProfileCache();
|
||||
|
||||
@@ -90,7 +89,7 @@ public class CustomSkinLoader {
|
||||
for(int i=0;i<config.loadlist.length;i++){
|
||||
SkinSiteProfile ssp=config.loadlist[i];
|
||||
logger.info((i+1)+"/"+config.loadlist.length+" Try to load profile from '"+ssp.name+"'.");
|
||||
IProfileLoader loader=LOADERS.get(ssp.type.toLowerCase());
|
||||
ProfileLoader.IProfileLoader loader=ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
|
||||
if(loader==null){
|
||||
logger.info("Type '"+ssp.type+"' is not defined.");
|
||||
continue;
|
||||
@@ -156,70 +155,4 @@ public class CustomSkinLoader {
|
||||
logger.info("Minecraft: "+MinecraftUtil.getMinecraftVersion());
|
||||
return logger;
|
||||
}
|
||||
|
||||
private static HashMap<String, IProfileLoader> initLoaders() {
|
||||
HashMap<String, IProfileLoader> loaders=new HashMap<String, IProfileLoader>();
|
||||
loaders.put("mojangapi", new MojangAPILoader());
|
||||
loaders.put("customskinapi", new JsonAPILoader(JsonAPILoader.Type.CustomSkinAPI));
|
||||
loaders.put("legacy", new LegacyLoader());
|
||||
loaders.put("uniskinapi", new JsonAPILoader(JsonAPILoader.Type.UniSkinAPI));
|
||||
return loaders;
|
||||
}
|
||||
|
||||
private static Config loadConfig0() {
|
||||
Config config=loadConfig();
|
||||
logger.info("Enable:"+config.enable+
|
||||
", EnableSkull:"+config.enableSkull+
|
||||
", EnableTranSkin:"+config.enableTransparentSkin+
|
||||
", CacheExpiry:"+config.cacheExpiry+
|
||||
", enableUpdateSkull:"+config.enableUpdateSkull+
|
||||
", LocalProfileCache:"+config.enableLocalProfileCache+
|
||||
", LoadList:"+(config.loadlist==null?0:config.loadlist.length));
|
||||
if(config.version==null||Float.parseFloat(CustomSkinLoader_VERSION)-Float.parseFloat(config.version)>0.01){
|
||||
logger.info("Config File is out of date: "+config.version);
|
||||
config.version=CustomSkinLoader_VERSION;
|
||||
writeConfig(config,true);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
private static Config loadConfig() {
|
||||
logger.info("Config File: "+CONFIG_FILE.getAbsolutePath());
|
||||
if(!CONFIG_FILE.exists()){
|
||||
logger.info("Config file not found, use default instead.");
|
||||
return initConfig();
|
||||
}
|
||||
try {
|
||||
logger.info("Try to load config.");
|
||||
String json=IOUtils.toString(new FileInputStream(CONFIG_FILE),Charsets.UTF_8);
|
||||
Config config=GSON.fromJson(json, Config.class);
|
||||
logger.info("Successfully load config.");
|
||||
return config;
|
||||
}catch (Exception e) {
|
||||
logger.info("Failed to load config, use default instead.("+e.toString()+")");
|
||||
File brokenFile=new File(DATA_DIR,"BROKEN-CustomSkinLoader.json");
|
||||
if(brokenFile.exists())
|
||||
brokenFile.delete();
|
||||
CONFIG_FILE.renameTo(brokenFile);
|
||||
return initConfig();
|
||||
}
|
||||
}
|
||||
|
||||
private static Config initConfig() {
|
||||
Config config=new Config(DEFAULT_LOAD_LIST);
|
||||
writeConfig(config,false);
|
||||
return config;
|
||||
}
|
||||
private static void writeConfig(Config config,boolean update){
|
||||
String json=GSON.toJson(config);
|
||||
if(CONFIG_FILE.exists())
|
||||
CONFIG_FILE.delete();
|
||||
try {
|
||||
CONFIG_FILE.createNewFile();
|
||||
IOUtils.write(json, new FileOutputStream(CONFIG_FILE),Charsets.UTF_8);
|
||||
logger.info("Successfully "+(update?"update":"create")+" config.");
|
||||
} catch (Exception e) {
|
||||
logger.info("Failed to "+(update?"update":"create")+" config.("+e.toString()+")");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,16 @@
|
||||
package customskinloader.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import customskinloader.CustomSkinLoader;
|
||||
import customskinloader.loader.ProfileLoader;
|
||||
|
||||
public class Config {
|
||||
public String version;
|
||||
@@ -17,4 +27,109 @@ public class Config {
|
||||
this.version=CustomSkinLoader.CustomSkinLoader_VERSION;
|
||||
this.loadlist=loadlist;
|
||||
}
|
||||
|
||||
public static Config loadConfig0() {
|
||||
Config config=loadConfig();
|
||||
config.loadExtraList();
|
||||
CustomSkinLoader.logger.info("Enable:"+config.enable+
|
||||
", EnableSkull:"+config.enableSkull+
|
||||
", EnableTranSkin:"+config.enableTransparentSkin+
|
||||
", CacheExpiry:"+config.cacheExpiry+
|
||||
", enableUpdateSkull:"+config.enableUpdateSkull+
|
||||
", LocalProfileCache:"+config.enableLocalProfileCache+
|
||||
", LoadList:"+(config.loadlist==null?0:config.loadlist.length));
|
||||
if(config.version==null||Float.parseFloat(CustomSkinLoader.CustomSkinLoader_VERSION)-Float.parseFloat(config.version)>0.01){
|
||||
CustomSkinLoader.logger.info("Config File is out of date: "+config.version);
|
||||
config.version=CustomSkinLoader.CustomSkinLoader_VERSION;
|
||||
writeConfig(config,true);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
private static Config loadConfig() {
|
||||
CustomSkinLoader.logger.info("Config File: "+CustomSkinLoader.CONFIG_FILE.getAbsolutePath());
|
||||
if(!CustomSkinLoader.CONFIG_FILE.exists()){
|
||||
CustomSkinLoader.logger.info("Config file not found, use default instead.");
|
||||
return initConfig();
|
||||
}
|
||||
try {
|
||||
CustomSkinLoader.logger.info("Try to load config.");
|
||||
String json=IOUtils.toString(new FileInputStream(CustomSkinLoader.CONFIG_FILE),Charsets.UTF_8);
|
||||
Config config=CustomSkinLoader.GSON.fromJson(json, Config.class);
|
||||
CustomSkinLoader.logger.info("Successfully load config.");
|
||||
return config;
|
||||
}catch (Exception e) {
|
||||
CustomSkinLoader.logger.info("Failed to load config, use default instead.("+e.toString()+")");
|
||||
File brokenFile=new File(CustomSkinLoader.DATA_DIR,"BROKEN-CustomSkinLoader.json");
|
||||
if(brokenFile.exists())
|
||||
brokenFile.delete();
|
||||
CustomSkinLoader.CONFIG_FILE.renameTo(brokenFile);
|
||||
return initConfig();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadExtraList(){
|
||||
File listAddition=new File(CustomSkinLoader.DATA_DIR,"ExtraList");
|
||||
if(!listAddition.isDirectory()){
|
||||
listAddition.mkdirs();
|
||||
return;
|
||||
}
|
||||
ArrayList<SkinSiteProfile> adds=new ArrayList<SkinSiteProfile>();
|
||||
File[] files=listAddition.listFiles();
|
||||
for(File file:files){
|
||||
if(!file.getName().endsWith(".json")&&!file.getName().endsWith(".txt"))
|
||||
continue;
|
||||
try {
|
||||
CustomSkinLoader.logger.info("Try to load Extra List.("+file.getName()+")");
|
||||
String json=IOUtils.toString(new FileInputStream(file),Charsets.UTF_8);
|
||||
SkinSiteProfile ssp=CustomSkinLoader.GSON.fromJson(json, SkinSiteProfile.class);
|
||||
CustomSkinLoader.logger.info("Successfully load Extra List.");
|
||||
file.delete();
|
||||
ProfileLoader.IProfileLoader loader=ProfileLoader.LOADERS.get(ssp.type.toLowerCase());
|
||||
if(loader==null){
|
||||
CustomSkinLoader.logger.info("Extra List will be ignore: Type '"+ssp.type+"' is not defined.");
|
||||
continue;
|
||||
}
|
||||
boolean duplicate=false;
|
||||
for(SkinSiteProfile ssp0:this.loadlist){
|
||||
if(!ssp0.type.equalsIgnoreCase(ssp.type))
|
||||
continue;
|
||||
if(loader.compare(ssp0, ssp)){
|
||||
duplicate=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!duplicate){
|
||||
adds.add(ssp);
|
||||
CustomSkinLoader.logger.info("Successfully apply Extra List.("+ssp.name+")");
|
||||
}else{
|
||||
CustomSkinLoader.logger.info("Extra List will be ignore: Duplicate.("+ssp.name+")");
|
||||
}
|
||||
}catch (Exception e) {
|
||||
CustomSkinLoader.logger.info("Failed to load Extra List.("+e.toString()+")");
|
||||
}
|
||||
}
|
||||
if(adds.size()!=0){
|
||||
this.loadlist=ArrayUtils.addAll((SkinSiteProfile[]) adds.toArray(),this.loadlist);
|
||||
writeConfig(this,true);
|
||||
}
|
||||
}
|
||||
|
||||
private static Config initConfig() {
|
||||
Config config=new Config(CustomSkinLoader.DEFAULT_LOAD_LIST);
|
||||
writeConfig(config,false);
|
||||
return config;
|
||||
}
|
||||
private static void writeConfig(Config config,boolean update){
|
||||
String json=CustomSkinLoader.GSON.toJson(config);
|
||||
if(CustomSkinLoader.CONFIG_FILE.exists())
|
||||
CustomSkinLoader.CONFIG_FILE.delete();
|
||||
try {
|
||||
CustomSkinLoader.CONFIG_FILE.createNewFile();
|
||||
IOUtils.write(json, new FileOutputStream(CustomSkinLoader.CONFIG_FILE),Charsets.UTF_8);
|
||||
CustomSkinLoader.logger.info("Successfully "+(update?"update":"create")+" config.");
|
||||
} catch (Exception e) {
|
||||
CustomSkinLoader.logger.info("Failed to "+(update?"update":"create")+" config.("+e.toString()+")");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package customskinloader.loader;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import customskinloader.config.SkinSiteProfile;
|
||||
import customskinloader.profile.UserProfile;
|
||||
|
||||
public interface IProfileLoader {
|
||||
public UserProfile loadProfile(SkinSiteProfile ssp,GameProfile gameProfile,boolean local) throws Exception;
|
||||
}
|
||||
@@ -18,7 +18,7 @@ import customskinloader.profile.UserProfile;
|
||||
import customskinloader.utils.HttpTextureUtil;
|
||||
import customskinloader.utils.HttpUtil0;
|
||||
|
||||
public class JsonAPILoader implements IProfileLoader {
|
||||
public class JsonAPILoader implements ProfileLoader.IProfileLoader {
|
||||
public static final String TEXTURES="textures/";
|
||||
public static enum Type{
|
||||
CustomSkinAPI(new CustomSkinAPI()),UniSkinAPI(new UniSkinAPI());
|
||||
@@ -62,4 +62,8 @@ public class JsonAPILoader implements IProfileLoader {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
|
||||
return ssp0.root.equalsIgnoreCase(ssp1.root);
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import customskinloader.profile.UserProfile;
|
||||
import customskinloader.utils.HttpTextureUtil;
|
||||
import customskinloader.utils.HttpUtil0;
|
||||
|
||||
public class LegacyLoader implements IProfileLoader {
|
||||
public class LegacyLoader implements ProfileLoader.IProfileLoader {
|
||||
public static final String USERNAME_REGEX="\\{USERNAME\\}";
|
||||
|
||||
@Override
|
||||
@@ -48,4 +48,9 @@ public class LegacyLoader implements IProfileLoader {
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
|
||||
return ssp0.skin.equalsIgnoreCase(ssp1.skin) || ssp0.cape.equalsIgnoreCase(ssp1.cape);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ import customskinloader.profile.UserProfile;
|
||||
import customskinloader.utils.HttpUtil0;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
public class MojangAPILoader implements IProfileLoader {
|
||||
public class MojangAPILoader implements ProfileLoader.IProfileLoader {
|
||||
|
||||
public static MinecraftSessionService defaultSessionService=null;
|
||||
@Override
|
||||
@@ -61,4 +61,8 @@ public class MojangAPILoader implements IProfileLoader {
|
||||
return null;
|
||||
return new GameProfile(gameProfile.getId(),gameProfile.getName());
|
||||
}
|
||||
@Override
|
||||
public boolean compare(SkinSiteProfile ssp0, SkinSiteProfile ssp1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package customskinloader.loader;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import customskinloader.config.SkinSiteProfile;
|
||||
import customskinloader.profile.UserProfile;
|
||||
|
||||
public class ProfileLoader {
|
||||
public static final HashMap<String,IProfileLoader> LOADERS=initLoaders();
|
||||
|
||||
private static HashMap<String, IProfileLoader> initLoaders() {
|
||||
HashMap<String, IProfileLoader> loaders=new HashMap<String, IProfileLoader>();
|
||||
loaders.put("mojangapi", new MojangAPILoader());
|
||||
loaders.put("customskinapi", new JsonAPILoader(JsonAPILoader.Type.CustomSkinAPI));
|
||||
loaders.put("legacy", new LegacyLoader());
|
||||
loaders.put("uniskinapi", new JsonAPILoader(JsonAPILoader.Type.UniSkinAPI));
|
||||
return loaders;
|
||||
}
|
||||
|
||||
public interface IProfileLoader {
|
||||
public UserProfile loadProfile(SkinSiteProfile ssp,GameProfile gameProfile,boolean local) throws Exception;
|
||||
public boolean compare(SkinSiteProfile ssp0,SkinSiteProfile ssp1);
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,8 @@ Custom Skin Loader mod for Minecraft.
|
||||
You can use it to load any skin from any website.
|
||||
|
||||
##Download
|
||||
Build Server:[Infinity Studio CI](https://ci.infstudio.net/job/CustomSkinLoader/)
|
||||
Release Page:[MCBBS](http://www.mcbbs.net/thread-269807-1-1.html)
|
||||
Build Server: [Infinity Studio CI](https://ci.infstudio.net/job/CustomSkinLoader/) [](https://ci.infstudio.net/job/CustomSkinLoader/)
|
||||
Release Page: [MCBBS](http://www.mcbbs.net/thread-269807-1-1.html)
|
||||
|
||||
##Feature
|
||||
###Plenty of Skin Load API Support and Customizable Skin Load List
|
||||
@@ -14,11 +14,12 @@ Skin Load API Supported:
|
||||
- [CustomSkinAPI](https://github.com/xfl03/CustomSkinLoaderAPI/tree/master/CustomSkinAPI)
|
||||
- [UniSkinAPI](https://github.com/RecursiveG/UniSkinServer/tree/master/doc)
|
||||
- Legacy
|
||||
|
||||
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.
|
||||
|
||||
###HD Skins Support
|
||||
Even though there is no Optifine, CustomSkinLoader has fix this problem.
|
||||
Even though there is no Optifine or MCPatcher, CustomSkinLoader has fix this problem.
|
||||
You can easily to get a better view in skin.
|
||||
|
||||
###Skull Support
|
||||
@@ -35,6 +36,10 @@ Furthermore, by using this function you can preview your skin in game and even c
|
||||
You can load local skin by using any API(excluding MojangAPI).
|
||||
*While using default configratulation, just put skin into `.minecraft/CustomSkinLoader/LocalSkin/(skin|cape)s/{USERNAME}.png`.
|
||||
|
||||
###Extra List
|
||||
A json file generated by supported skin server.
|
||||
To add server to load list, users just need to put file into `.minecraft/CustomSkinLoader/ExtraList` .
|
||||
|
||||
###Transparent Skin Support
|
||||
*Should be open in configratulation file.
|
||||
|
||||
@@ -52,6 +57,7 @@ CustomSkinLoader is designed for loading from any server, which makes it complex
|
||||
It's not a good idea to refer to CustomSkinLoader's source code to develop your own skin mod.
|
||||
It's recommended to use CustomSkinLoader for your server directly.
|
||||
Furthermore, you can add your server to 'Default Load List'.
|
||||
You also can use 'ExtraList' which makes it easier for user to adds your server into load list.
|
||||
|
||||
##Copyright & LICENSE
|
||||
###Binary File
|
||||
|
||||
+1
-1
@@ -3,4 +3,4 @@ group=customskinloader
|
||||
version=14.4
|
||||
dev_version=
|
||||
#RELEASE: snapshot_version=
|
||||
snapshot_version=20160820
|
||||
snapshot_version=20160821
|
||||
Reference in new issue
Block a user