mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-28 05:35:44 +00:00
Added Config File Updater
Added Transparent Skin Support Tweaked UniSkinAPI Log Added Config for Skull and Transparent Skin Added a new skin site
This commit is contained in:
1 parent
1dbfa30ba8
commit
4142609635
8 files changed
+65
-22
No files matched your search
+11
-9
@@ -42,15 +42,17 @@ public class ImageBufferDownload implements IImageBuffer
|
||||
}
|
||||
var3.dispose();
|
||||
this.imageData = ((DataBufferInt)var2.getRaster().getDataBuffer()).getData();
|
||||
this.setAreaOpaque(0, 0, 32 * ratio, 16 * ratio);
|
||||
this.setAreaTransparent(32 * ratio, 0, 64 * ratio, 32 * ratio);
|
||||
this.setAreaOpaque(0, 16 * ratio, 64 * ratio, 32 * ratio);
|
||||
this.setAreaTransparent(0, 32 * ratio, 16 * ratio, 48 * ratio);
|
||||
this.setAreaTransparent(16 * ratio, 32 * ratio, 40 * ratio, 48 * ratio);
|
||||
this.setAreaTransparent(40 * ratio, 32 * ratio, 56 * ratio, 48 * ratio);
|
||||
this.setAreaTransparent(0, 48 * ratio, 16 * ratio, 64 * ratio);
|
||||
this.setAreaOpaque(16 * ratio, 48 * ratio, 48 * ratio, 64 * ratio);
|
||||
this.setAreaTransparent(48 * ratio, 48 * ratio, 64 * ratio, 64 * ratio);
|
||||
if(!customskinloader.CustomSkinLoader.config.enableTransparentSkin){
|
||||
this.setAreaOpaque(0, 0, 32 * ratio, 16 * ratio);
|
||||
this.setAreaTransparent(32 * ratio, 0, 64 * ratio, 32 * ratio);
|
||||
this.setAreaOpaque(0, 16 * ratio, 64 * ratio, 32 * ratio);
|
||||
this.setAreaTransparent(0, 32 * ratio, 16 * ratio, 48 * ratio);
|
||||
this.setAreaTransparent(16 * ratio, 32 * ratio, 40 * ratio, 48 * ratio);
|
||||
this.setAreaTransparent(40 * ratio, 32 * ratio, 56 * ratio, 48 * ratio);
|
||||
this.setAreaTransparent(0, 48 * ratio, 16 * ratio, 64 * ratio);
|
||||
this.setAreaOpaque(16 * ratio, 48 * ratio, 48 * ratio, 64 * ratio);
|
||||
this.setAreaTransparent(48 * ratio, 48 * ratio, 64 * ratio, 64 * ratio);
|
||||
}
|
||||
return var2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,9 +129,9 @@ public class SkinManager
|
||||
map.putAll(SkinManager.this.sessionService.getTextures(profile, false));
|
||||
}*/
|
||||
|
||||
//CustomSkinLoader Begin
|
||||
//CustomSkinLoader Begin (User Skin/Cape Part)
|
||||
if(customskinloader.CustomSkinLoader.config.enable){
|
||||
Map<Type, MinecraftProfileTexture> newMap=customskinloader.CustomSkinLoader.loadProfile(profile.getName(), map);
|
||||
Map newMap=customskinloader.CustomSkinLoader.loadProfile(profile.getName(), map);
|
||||
if(!newMap.isEmpty()){
|
||||
map.clear();
|
||||
map.putAll(newMap);
|
||||
@@ -159,8 +159,12 @@ public class SkinManager
|
||||
|
||||
public Map<Type, MinecraftProfileTexture> loadSkinFromCache(GameProfile profile)
|
||||
{
|
||||
return customskinloader.CustomSkinLoader.loadProfileFromCache(profile.getName());
|
||||
//return (Map)this.skinCacheLoader.getUnchecked(profile);
|
||||
//CustomSkinLoader Begin (Skull Part)
|
||||
//return (Map)this.skinCacheLoader.getUnchecked(profile);
|
||||
return (customskinloader.CustomSkinLoader.config.enable && customskinloader.CustomSkinLoader.config.enableSkull)?
|
||||
customskinloader.CustomSkinLoader.loadProfileFromCache(profile.getName()):
|
||||
this.skinCacheLoader.getUnchecked(profile);
|
||||
//CustomSkinLoader End
|
||||
}
|
||||
|
||||
public interface SkinAvailableCallback
|
||||
|
||||
@@ -39,7 +39,8 @@ public class CustomSkinLoader {
|
||||
new SkinSiteProfile("BlessingSkin","CustomSkinAPI","https://skin.prinzeugen.net/csl/"),
|
||||
//Minecrack could not load skin correctly
|
||||
//new SkinSiteProfile("Minecrack","Legacy","http://minecrack.fr.nf/mc/skinsminecrackd/{USERNAME}.png","http://minecrack.fr.nf/mc/cloaksminecrackd/{USERNAME}.png"),
|
||||
new SkinSiteProfile("SkinMe","UniSkinAPI","http://www.skinme.cc/uniskin/")};
|
||||
new SkinSiteProfile("SkinMe","UniSkinAPI","http://www.skinme.cc/uniskin/"),
|
||||
new SkinSiteProfile("McSkin","CustomSkinAPI","http://www.mcskin.cc/")};
|
||||
public static final HashMap<String,IProfileLoader> LOADERS=initLoaders();
|
||||
|
||||
public static final Logger logger=initLogger();
|
||||
@@ -94,6 +95,7 @@ public class CustomSkinLoader {
|
||||
logger.info(username+"'s profile not found.");
|
||||
return defaultProfile;
|
||||
}
|
||||
//For Skull (1.8.2 and Higher)
|
||||
public static Map<Type, MinecraftProfileTexture> loadProfileFromCache(String username) {
|
||||
if(profileCache.containsKey(username)){
|
||||
UserProfile profile=profileCache.get(username);
|
||||
@@ -101,6 +103,15 @@ public class CustomSkinLoader {
|
||||
}
|
||||
return loadProfile(username,(Map)null);
|
||||
}
|
||||
//For Skull (1.8.1 and Lower)
|
||||
public static String loadSkinFromCache(String username) {
|
||||
if(profileCache.containsKey(username)){
|
||||
UserProfile profile=profileCache.get(username);
|
||||
return profile==null?null:profile.skinUrl;
|
||||
}
|
||||
UserProfile profile=loadProfile(username,(UserProfile)null);
|
||||
return profile==null?null:profile.skinUrl;
|
||||
}
|
||||
|
||||
private static Logger initLogger() {
|
||||
Logger logger=new Logger(LOG_FILE);
|
||||
@@ -122,6 +133,11 @@ public class CustomSkinLoader {
|
||||
Config config=loadConfig();
|
||||
logger.info("Enable: "+config.enable);
|
||||
logger.info("LoadList: "+(config.loadlist==null?0:config.loadlist.length));
|
||||
if(config.version==null||Float.parseFloat(config.version)<Float.parseFloat(CustomSkinLoader_VERSION)){
|
||||
logger.info("Config File is out of date: "+config.version);
|
||||
config.version=CustomSkinLoader_VERSION;
|
||||
writeConfig(config,true);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -145,6 +161,10 @@ public class CustomSkinLoader {
|
||||
|
||||
private static Config initConfig() {
|
||||
Config config=new Config(DEFAULT_LOAD_LIST);
|
||||
writeConfig(config,false);
|
||||
return config;
|
||||
}
|
||||
private static void writeConfig(Config config,boolean update){
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
String json=gson.toJson(config);
|
||||
if(CONFIG_FILE.exists())
|
||||
@@ -152,10 +172,9 @@ public class CustomSkinLoader {
|
||||
try {
|
||||
CONFIG_FILE.createNewFile();
|
||||
IOUtils.write(json, new FileOutputStream(CONFIG_FILE));
|
||||
logger.info("Successfully create config.");
|
||||
logger.info("Successfully "+(update?"update":"create")+" config.");
|
||||
} catch (Exception e) {
|
||||
logger.info("Failed to create config.("+e.getMessage()+")");
|
||||
logger.info("Failed to "+(update?"update":"create")+" config.("+e.getMessage()+")");
|
||||
}
|
||||
return config;
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,6 @@ public class UserProfile {
|
||||
* @return status (true - empty)
|
||||
*/
|
||||
public boolean isEmpty(){
|
||||
return skinUrl==null && model==null && capeUrl==null;
|
||||
return skinUrl==null && (model==null||model.equalsIgnoreCase("default")) && capeUrl==null;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,17 @@
|
||||
package customskinloader.config;
|
||||
|
||||
import customskinloader.CustomSkinLoader;
|
||||
|
||||
public class Config {
|
||||
public boolean enable;
|
||||
public String version;
|
||||
public boolean enable=true;
|
||||
public boolean enableSkull=true;
|
||||
public boolean enableTransparentSkin=false;
|
||||
public SkinSiteProfile[] loadlist;
|
||||
|
||||
//Init config
|
||||
public Config(SkinSiteProfile[] loadlist){
|
||||
this.enable=true;
|
||||
this.version=CustomSkinLoader.CustomSkinLoader_VERSION;
|
||||
this.loadlist=loadlist;
|
||||
}
|
||||
}
|
||||
@@ -6,22 +6,27 @@ public class SkinSiteProfile {
|
||||
public String root;
|
||||
public String skin;
|
||||
public String cape;
|
||||
public String model;
|
||||
|
||||
//For MojangAPI
|
||||
public SkinSiteProfile(String name,String type){
|
||||
this.name=name;
|
||||
this.type=type;
|
||||
}
|
||||
|
||||
//For CSL/USM API
|
||||
public SkinSiteProfile(String name,String type,String root){
|
||||
this.name=name;
|
||||
this.type=type;
|
||||
this.root=root;
|
||||
}
|
||||
|
||||
public SkinSiteProfile(String name,String type,String skin,String cape){
|
||||
//for Legacy
|
||||
public SkinSiteProfile(String name,String type,String skin,String cape,String model){
|
||||
this.name=name;
|
||||
this.type=type;
|
||||
this.skin=skin;
|
||||
this.cape=cape;
|
||||
this.model=model;
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ public class LegacyLoader implements IProfileLoader {
|
||||
String skin=HttpUtil0.getRealUrl(ssp.skin.replaceAll(USERNAME_REGEX, username));
|
||||
if(skin!=null&&!skin.equals("")){
|
||||
profile.skinUrl=skin;
|
||||
profile.model="default";
|
||||
profile.model=(ssp.model==null?"default":ssp.model);
|
||||
}
|
||||
}
|
||||
if(ssp.cape!=null && !ssp.cape.equals("")){
|
||||
|
||||
@@ -25,6 +25,10 @@ public class UniSkinAPILoader implements IProfileLoader {
|
||||
return null;
|
||||
}
|
||||
UniSkinAPI profile=new Gson().fromJson(json, UniSkinAPI.class);
|
||||
if(profile.errno!=0){
|
||||
CustomSkinLoader.logger.info("Error: "+profile.msg);
|
||||
return null;
|
||||
}
|
||||
UserProfile p=new UserProfile();
|
||||
if(profile.skins!=null && !profile.skins.isEmpty()){
|
||||
if(profile.model_preference!=null && !profile.model_preference.isEmpty()){
|
||||
@@ -69,5 +73,8 @@ public class UniSkinAPILoader implements IProfileLoader {
|
||||
public List<String> model_preference;
|
||||
public Map<String,String> skins;
|
||||
public String cape;
|
||||
|
||||
public int errno;
|
||||
public String msg;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user