From 2f26a07dc934166322ef8b7e159fc85beaf7d088 Mon Sep 17 00:00:00 2001 From: ZekerZhayard Date: Fri, 24 Jan 2025 14:27:55 +0800 Subject: [PATCH] Fix local profile cache. (#327) --- Common/src/main/java/customskinloader/CustomSkinLoader.java | 2 +- .../main/java/customskinloader/profile/ProfileCache.java | 6 +++--- .../src/main/java/customskinloader/profile/UserProfile.java | 2 ++ build.properties | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Common/src/main/java/customskinloader/CustomSkinLoader.java b/Common/src/main/java/customskinloader/CustomSkinLoader.java index f37dab7..17c3f5d 100644 --- a/Common/src/main/java/customskinloader/CustomSkinLoader.java +++ b/Common/src/main/java/customskinloader/CustomSkinLoader.java @@ -180,7 +180,7 @@ public class CustomSkinLoader { if (config.enableLocalProfileCache) { UserProfile profile = profileCache.getLocalProfile(credential); - if (profile == null) { + if (profile == null || profile.equals(UserProfile.NULL)) { logger.info(username + "'s LocalProfile not found."); } else { profileCache.updateCache(credential, profile, false); diff --git a/Common/src/main/java/customskinloader/profile/ProfileCache.java b/Common/src/main/java/customskinloader/profile/ProfileCache.java index e7853d0..2b54238 100644 --- a/Common/src/main/java/customskinloader/profile/ProfileCache.java +++ b/Common/src/main/java/customskinloader/profile/ProfileCache.java @@ -89,7 +89,7 @@ public class ProfileCache { private UserProfile loadLocalProfile(String username){ File localProfile=new File(PROFILE_CACHE_DIR,username.toLowerCase()+".json"); if(!localProfile.exists()){ - localProfiles.put(username.toLowerCase(), null); + localProfiles.put(username.toLowerCase(), UserProfile.NULL); } try{ String json = FileUtils.readFileToString(localProfile, "UTF-8"); @@ -99,9 +99,9 @@ public class ProfileCache { return profile; }catch(Exception e){ CustomSkinLoader.logger.info("Failed to load LocalProfile.("+e.toString()+")"); - localProfiles.put(username.toLowerCase(), null); + localProfiles.put(username.toLowerCase(), UserProfile.NULL); } - return null; + return UserProfile.NULL; } @SuppressWarnings("ResultOfMethodCallIgnored") private void saveLocalProfile(String username, UserProfile profile){ diff --git a/Common/src/main/java/customskinloader/profile/UserProfile.java b/Common/src/main/java/customskinloader/profile/UserProfile.java index 831d917..b183d7a 100644 --- a/Common/src/main/java/customskinloader/profile/UserProfile.java +++ b/Common/src/main/java/customskinloader/profile/UserProfile.java @@ -15,6 +15,8 @@ import customskinloader.profile.ModelManager0.Model; * @since 13.1 */ public class UserProfile { + + public final static UserProfile NULL = new UserProfile(); /** * Direct url for skin. diff --git a/build.properties b/build.properties index 9f03802..053053b 100644 --- a/build.properties +++ b/build.properties @@ -1,3 +1,3 @@ name=CustomSkinLoader group=customskinloader -version=14.22 +version=14.22.1