9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-25 18:09:17 +00:00

rewritten profile cache (#415)

* rewritten profile cache

* cleanup

* Fix build

* Update comments
This commit is contained in:
Taiyou
2025-07-24 22:48:54 +02:00
committed by GitHub
parent 3b9d8feb03
commit 006fe7ce3a
147 changed files with 202 additions and 151 deletions

View File

@@ -1,29 +0,0 @@
package org.dreeam.leaf.config.modules.misc;
import org.dreeam.leaf.config.ConfigModules;
import org.dreeam.leaf.config.EnumConfigCategory;
public class Cache extends ConfigModules {
public String getBasePath() {
return EnumConfigCategory.MISC.getBaseKeyName() + ".cache";
}
public static boolean cachePlayerProfileResult = false;
public static int cachePlayerProfileResultTimeout = 1440;
@Override
public void onLoaded() {
cachePlayerProfileResult = config.getBoolean(getBasePath() + ".cache-player-profile-result", cachePlayerProfileResult, config.pickStringRegionBased("""
Cache the player profile result on they first join.
It's useful if Mojang's verification server is down.""",
"""
玩家首次加入时缓存 PlayerProfile.
正版验证服务器宕机时非常有用."""));
cachePlayerProfileResultTimeout = config.getInt(getBasePath() + ".cache-player-profile-result-timeout", cachePlayerProfileResultTimeout,
config.pickStringRegionBased(
"The timeout of the cache. Unit: Minutes.",
"缓存过期时间. 单位: 分钟."
));
}
}

View File

@@ -0,0 +1,31 @@
package org.dreeam.leaf.config.modules.misc;
import org.dreeam.leaf.config.ConfigModules;
import org.dreeam.leaf.config.EnumConfigCategory;
public class CacheProfileLookup extends ConfigModules {
public String getBasePath() {
return EnumConfigCategory.MISC.getBaseKeyName() + ".cache.profile-lookup";
}
public static boolean enabled = false;
public static int timeout = 1440; // 24 hours in minutes
public static int maxSize = 8192;
@Override
public void onLoaded() {
enabled = config.getBoolean(getBasePath() + ".enabled", enabled, config.pickStringRegionBased("""
Cache profile data lookups (skins, textures, etc.) to reduce API calls to Mojang.""",
"""
缓存玩家资料查询 (皮肤, 材质等) 以减少对 Mojang API 的调用."""));
timeout = config.getInt(getBasePath() + ".timeout", timeout, config.pickStringRegionBased(
"The timeout for profile lookup cache. Unit: Minutes.",
"玩家资料查询缓存过期时间. 单位: 分钟. (推荐: 1440 = 24小时)"
));
maxSize = config.getInt(getBasePath() + ".max-size", maxSize, config.pickStringRegionBased(
"Maximum number of profiles to cache. Higher values use more memory (not that much).",
"最大缓存的玩家资料数量. 更高的值会使用更多内存."
));
}
}