diff --git a/Common/source/customskinloader/CustomSkinLoader.java b/Common/source/customskinloader/CustomSkinLoader.java index 7bd2b34..b2f129e 100644 --- a/Common/source/customskinloader/CustomSkinLoader.java +++ b/Common/source/customskinloader/CustomSkinLoader.java @@ -161,7 +161,7 @@ public class CustomSkinLoader { if(username == null || credential == null) return dynamicSkullManager.getTexture(gameProfile); - if(config.enableUpdateSkull?profileCache.isReady(credential):profileCache.isExist(credential)){ + if(config.forceUpdateSkull ?profileCache.isReady(credential):profileCache.isExist(credential)){ UserProfile profile=profileCache.getProfile(credential); return ModelManager0.fromUserProfile(profile); } @@ -173,7 +173,7 @@ public class CustomSkinLoader { loadProfile0(gameProfile);//Load in thread Thread.currentThread().setName(tempName); }; - if (config.enableUpdateSkull) { + if (config.forceUpdateSkull) { new Thread(loadThread).start(); } else { threadPool.execute(loadThread); diff --git a/Common/source/customskinloader/config/Config.java b/Common/source/customskinloader/config/Config.java index af69b8d..ec11218 100644 --- a/Common/source/customskinloader/config/Config.java +++ b/Common/source/customskinloader/config/Config.java @@ -24,7 +24,7 @@ public class Config { //Function public boolean enableDynamicSkull=true; public boolean enableTransparentSkin=true; - public boolean ignoreHttpsCertificate=false; + public boolean forceIgnoreHttpsCertificate = false; public boolean forceLoadAllTextures=false; public boolean enableCape = true; public int threadPoolSize = 1; @@ -32,9 +32,10 @@ public class Config { //Cache public int cacheExpiry=30; - public boolean enableUpdateSkull=false; + public boolean forceUpdateSkull = false; public boolean enableLocalProfileCache=false; public boolean enableCacheAutoClean=false; + public boolean forceDisableCache = false; //Init config public Config(SkinSiteProfile[] loadlist){ @@ -60,7 +61,7 @@ public class Config { config.initLocalFolder(); config.threadPoolSize = Math.max(config.threadPoolSize, 1); config.retryTime = Math.max(config.retryTime, 0); - if(config.ignoreHttpsCertificate) + if(config.forceIgnoreHttpsCertificate) HttpUtil0.ignoreHttpsCertificate(); if(config.enableCacheAutoClean && !config.enableLocalProfileCache){ try{ diff --git a/Common/source/customskinloader/loader/MojangAPILoader.java b/Common/source/customskinloader/loader/MojangAPILoader.java index 5e0b848..6dce47d 100644 --- a/Common/source/customskinloader/loader/MojangAPILoader.java +++ b/Common/source/customskinloader/loader/MojangAPILoader.java @@ -60,7 +60,7 @@ public class MojangAPILoader implements ProfileLoader.IProfileLoader { HttpResponce responce = HttpRequestUtil.makeHttpRequest( new HttpRequest(apiRoot + "profiles/minecraft") - .setCacheTime(-1).setPayload(gson.toJson(Collections.singletonList(username))) + .setCacheTime(600).setPayload(gson.toJson(Collections.singletonList(username))) ); if (StringUtils.isEmpty(responce.content)) return null; diff --git a/Common/source/customskinloader/utils/HttpRequestUtil.java b/Common/source/customskinloader/utils/HttpRequestUtil.java index 246c2ab..a555ca9 100644 --- a/Common/source/customskinloader/utils/HttpRequestUtil.java +++ b/Common/source/customskinloader/utils/HttpRequestUtil.java @@ -7,6 +7,7 @@ import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URI; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.GZIPInputStream; @@ -26,7 +27,11 @@ public class HttpRequestUtil { public boolean loadContent = true; public boolean checkPNG = false; - public int cacheTime = 600;//-1=No Cache 0=Always Cache t=Default Cache Time(second) + /** + * Cache Time + * -1=No Cache 0=Always Cache t=Default Cache Time(second) + */ + public int cacheTime = 600; public File cacheFile = null;//Default Cache File public HttpRequest(String url) { @@ -93,8 +98,9 @@ public class HttpRequestUtil { } CustomSkinLoader.logger.debug("Try to request '" + request.url + (request.userAgent == null ? "'." : "' with user agent '" + request.userAgent + "'.")); //Check Cache - if (StringUtils.isNotEmpty(request.payload)) + if (StringUtils.isNotEmpty(request.payload) || CustomSkinLoader.config.forceDisableCache){ request.cacheTime = -1;//No Cache + } File cacheInfoFile = null; CacheInfo cacheInfo = new CacheInfo(); if (request.cacheFile == null && request.cacheTime >= 0) { @@ -203,7 +209,7 @@ public class HttpRequestUtil { } if (!request.loadContent) return responce; - responce.content = new String(bytes, "UTF-8"); + responce.content = new String(bytes, StandardCharsets.UTF_8); CustomSkinLoader.logger.debug("Content: " + responce.content); return responce; @@ -254,7 +260,6 @@ public class HttpRequestUtil { long expires = connection.getExpiration(); if (expires > 0) return expires / 1000; - return TimeUtil.getUnixTimestampRandomDelay(cacheTime == 0 ? 86400 : cacheTime); - + return TimeUtil.getUnixTimestampRandomDelay(cacheTime == 0 ? 2592000 : cacheTime); } }