From 2a5b8270818dca050feab97c4b066f22c16c8344 Mon Sep 17 00:00:00 2001 From: Justin Widen Date: Tue, 30 Dec 2025 23:13:11 -0600 Subject: [PATCH 1/4] Fixed overwriting existing config Fixed overwriting existing config file on every start of the mod. Now changes to the config will actually persist. --- src/main/java/cn/alini/offlineauth/OfflineAuthHandler.java | 2 +- src/main/java/cn/alini/offlineauth/Offlineauth.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/cn/alini/offlineauth/OfflineAuthHandler.java b/src/main/java/cn/alini/offlineauth/OfflineAuthHandler.java index c747775..4d962a0 100644 --- a/src/main/java/cn/alini/offlineauth/OfflineAuthHandler.java +++ b/src/main/java/cn/alini/offlineauth/OfflineAuthHandler.java @@ -44,7 +44,7 @@ public class OfflineAuthHandler { private static final Gson gson = new Gson(); private static final Map autoLoginMap = new HashMap<>(); private static final Map failMap = new HashMap<>(); - static { loadAutoLogin(); loadFail(); } + static { config.load(); loadAutoLogin(); loadFail(); } private static boolean isOfflinePlayer(ServerPlayer player) { return !TrueuuidApi.isPremium(player.getName().getString().toLowerCase(Locale.ROOT)); diff --git a/src/main/java/cn/alini/offlineauth/Offlineauth.java b/src/main/java/cn/alini/offlineauth/Offlineauth.java index 38d47b5..9f8dc83 100644 --- a/src/main/java/cn/alini/offlineauth/Offlineauth.java +++ b/src/main/java/cn/alini/offlineauth/Offlineauth.java @@ -13,6 +13,5 @@ public class Offlineauth { public Offlineauth() { //mod成功加载日志 LOGGER.info("OfflineAuth mod loaded successfully!"); - new AuthConfig().save(); } } From 0ec9a6098a09b2542c96e13f31b12eb7006a31ed Mon Sep 17 00:00:00 2001 From: Justin Widen Date: Tue, 30 Dec 2025 23:15:41 -0600 Subject: [PATCH 2/4] Update trueuuid version and mod version trueuuid library from 1.0.2 to 1.0.5 in build.gradle and changed mod_version to 1.0.3 in gradle.properties. --- build.gradle | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 7997ff1..0185c69 100644 --- a/build.gradle +++ b/build.gradle @@ -149,7 +149,7 @@ dependencies { // If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"], // then special handling is done to allow a setup of a vanilla dependency without the use of an external repository. minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" - implementation files('libs/trueuuid-1.0.2.jar') + implementation files('libs/trueuuid-1.0.5.jar') // Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings // The JEI API is declared for compile time use, while the full JEI artifact is used at runtime // compileOnly fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}") diff --git a/gradle.properties b/gradle.properties index 261059b..41c7b08 100644 --- a/gradle.properties +++ b/gradle.properties @@ -38,7 +38,7 @@ mod_name=OfflineAuth # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=GNU LGPL 3.0 # The mod version. See https://semver.org/ -mod_version=1.0.1 +mod_version=1.0.3 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html From c884a2e5a3d12024f62bb3d3739da01477b2d2de Mon Sep 17 00:00:00 2001 From: Justin Widen Date: Wed, 31 Dec 2025 01:00:51 -0600 Subject: [PATCH 3/4] Config reload command Added '/reload' command for reloading configuration while running, available to users with permission level 2, and added success message. --- gradle.properties | 2 +- src/main/java/cn/alini/offlineauth/AuthConfig.java | 1 + .../java/cn/alini/offlineauth/OfflineAuthHandler.java | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 41c7b08..2fe92db 100644 --- a/gradle.properties +++ b/gradle.properties @@ -38,7 +38,7 @@ mod_name=OfflineAuth # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=GNU LGPL 3.0 # The mod version. See https://semver.org/ -mod_version=1.0.3 +mod_version=1.0.4 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/cn/alini/offlineauth/AuthConfig.java b/src/main/java/cn/alini/offlineauth/AuthConfig.java index 31a92ad..e85fee2 100644 --- a/src/main/java/cn/alini/offlineauth/AuthConfig.java +++ b/src/main/java/cn/alini/offlineauth/AuthConfig.java @@ -55,6 +55,7 @@ public AuthConfig() { messages.put("help_login", "§e/login 密码 §7- 登录账户"); messages.put("help_changepwd", "§e/changepassword 旧密码 新密码 §7- 修改密码"); messages.put("auto_login_warn", "§e⚠已启用自动登录(同IP设备短时间内无需重复登录)。如在网吧/公共电脑请勿使用此功能,避免账号被盗。"); + messages.put("reload_success", "§a配置已重载!"); // 正确做法:在构造后,手动调用 load(),不要在构造里调用 // 由主类 new AuthConfig 后,再调用 config.load() diff --git a/src/main/java/cn/alini/offlineauth/OfflineAuthHandler.java b/src/main/java/cn/alini/offlineauth/OfflineAuthHandler.java index 4d962a0..ba500e2 100644 --- a/src/main/java/cn/alini/offlineauth/OfflineAuthHandler.java +++ b/src/main/java/cn/alini/offlineauth/OfflineAuthHandler.java @@ -546,6 +546,14 @@ public static void registerCommands(RegisterCommandsEvent event) { return 1; }) ) + .then(Commands.literal("reload") + .requires(source -> source.hasPermission(2)) + .executes(ctx -> { + config.load(); + ctx.getSource().sendSuccess(() -> Component.literal(config.msg("reload_success")), true); + return 1; + }) + ) ); } } \ No newline at end of file From 87c358656c19a48089ef88a8caf512403b1d0c87 Mon Sep 17 00:00:00 2001 From: Justin Widen Date: Wed, 31 Dec 2025 15:36:21 -0600 Subject: [PATCH 4/4] Add reload command to README --- README.md | 1 + README_zh-CN.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 184112e..f83b655 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Supports registration, login, inventory protection, brute-force prevention, and - `/login ` — Login to your account. - `/changepassword ` — Change your password. - `/auth help` — Show help information. +- `/auth reload` — Reload the configuration file (requires permission level 2). ## Configuration diff --git a/README_zh-CN.md b/README_zh-CN.md index df58081..28e1b82 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -22,6 +22,7 @@ - `/login <密码>` — 登录账户 - `/changepassword <旧密码> <新密码>` — 修改密码 - `/auth help` — 查看帮助信息 +- `/auth reload` — 重载配置文件(需要权限等级 2) ## 配置说明