From eed5ce1b7b7ce4b422c50df135911f5be158f07a Mon Sep 17 00:00:00 2001 From: HaHaWTH Date: Sun, 12 Nov 2023 14:12:11 +0800 Subject: [PATCH] Localized LoginLocationFix --- .../listener/LoginLocationFixListener.java | 10 +++++++--- .../java/fr/xephi/authme/message/MessageKey.java | 16 ++++++++++++++++ .../authme/message/updater/MessageUpdater.java | 1 + src/main/resources/messages/messages_en.yml | 6 ++++++ src/main/resources/messages/messages_zhcn.yml | 6 ++++++ 5 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/main/java/fr/xephi/authme/listener/LoginLocationFixListener.java b/src/main/java/fr/xephi/authme/listener/LoginLocationFixListener.java index 04faf801..0b75c382 100644 --- a/src/main/java/fr/xephi/authme/listener/LoginLocationFixListener.java +++ b/src/main/java/fr/xephi/authme/listener/LoginLocationFixListener.java @@ -2,6 +2,8 @@ package fr.xephi.authme.listener; import fr.xephi.authme.AuthMe; import fr.xephi.authme.api.v3.AuthMeApi; +import fr.xephi.authme.message.MessageKey; +import fr.xephi.authme.message.Messages; import fr.xephi.authme.settings.properties.SecuritySettings; import fr.xephi.authme.util.TeleportUtils; import org.bukkit.Location; @@ -20,6 +22,8 @@ import javax.inject.Inject; public class LoginLocationFixListener implements Listener { @Inject private AuthMe plugin; + @Inject + private Messages messages; private final AuthMeApi authmeApi = AuthMeApi.getInstance(); public LoginLocationFixListener() { @@ -65,7 +69,7 @@ public class LoginLocationFixListener implements Listener { JoinBlock.getRelative(BlockFace.UP).breakNaturally(); JoinBlock.breakNaturally(); } - player.sendMessage("§a你在登录时卡在了地狱门, 现已修正"); + messages.send(player, MessageKey.LOCATION_FIX_PORTAL); } else if (isFixGroundStuck) { Material UpType = JoinLocation.getBlock().getRelative(BlockFace.UP).getType(); World world = player.getWorld(); @@ -88,7 +92,7 @@ public class LoginLocationFixListener implements Listener { } else { player.teleport(JoinBlock.getLocation().add(0.5, 0.1, 0.5)); } - player.sendMessage("§a你被埋住了, 坐标已修正, 下次下线之前请小心!"); + messages.send(player, MessageKey.LOCATION_FIX_UNDERGROUND); break; } if (i == MaxHeight) { @@ -97,7 +101,7 @@ public class LoginLocationFixListener implements Listener { } else { player.teleport(JoinBlock.getLocation().add(0.5, 1.1, 0.5)); } - player.sendMessage("§a你被埋住了, 坐标无法修正, 只好送你去了最高点, 自求多福吧少年~"); + messages.send(player, MessageKey.LOCATION_FIX_UNDERGROUND_CANT_FIX); } } } diff --git a/src/main/java/fr/xephi/authme/message/MessageKey.java b/src/main/java/fr/xephi/authme/message/MessageKey.java index 052a8d9d..35df8bf1 100644 --- a/src/main/java/fr/xephi/authme/message/MessageKey.java +++ b/src/main/java/fr/xephi/authme/message/MessageKey.java @@ -4,6 +4,22 @@ package fr.xephi.authme.message; * Keys for translatable messages managed by {@link Messages}. */ public enum MessageKey { + + /** + * You are stuck in portal during Login. + */ + LOCATION_FIX_PORTAL("login_location_fix.fix_portal"), + + /** + * You are stuck underground during Login. + */ + LOCATION_FIX_UNDERGROUND("login_location_fix.fix_underground"), + + /** + * You are stuck underground during Login, but we cant fix it. + */ + LOCATION_FIX_UNDERGROUND_CANT_FIX("login_location_fix.cannot_fix_underground"), + /** * Bedrock auto login success! */ diff --git a/src/main/java/fr/xephi/authme/message/updater/MessageUpdater.java b/src/main/java/fr/xephi/authme/message/updater/MessageUpdater.java index 0e267665..58f9f47a 100644 --- a/src/main/java/fr/xephi/authme/message/updater/MessageUpdater.java +++ b/src/main/java/fr/xephi/authme/message/updater/MessageUpdater.java @@ -151,6 +151,7 @@ public class MessageUpdater { .put("two_factor", "Two-factor authentication") .put("gui_captcha", "3rd party features: GUI Captcha") .put("bedrock_auto_login", "3rd party features: Bedrock Auto Login") + .put("login_location_fix", "3rd party features: Login Location Fix") .build(); Set addedKeys = new HashSet<>(); diff --git a/src/main/resources/messages/messages_en.yml b/src/main/resources/messages/messages_en.yml index 8a74d646..c88069b6 100644 --- a/src/main/resources/messages/messages_en.yml +++ b/src/main/resources/messages/messages_en.yml @@ -170,3 +170,9 @@ gui_captcha: # 3rd party features: Bedrock Auto Login bedrock_auto_login: success: '&aBedrock auto login success!' + +# 3rd party features: Login Location Fix +login_location_fix: + fix_portal: '&aYou are stuck in portal during Login.' + fix_underground: '&aYou are stuck underground during Login.' + cannot_fix_underground: '&aYou are stuck underground during Login, but we cant fix it.' diff --git a/src/main/resources/messages/messages_zhcn.yml b/src/main/resources/messages/messages_zhcn.yml index aa8c394c..f839af70 100644 --- a/src/main/resources/messages/messages_zhcn.yml +++ b/src/main/resources/messages/messages_zhcn.yml @@ -179,3 +179,9 @@ gui_captcha: # 3rd party features: Bedrock Auto Login bedrock_auto_login: success: "&a基岩版自动登录完成" + +# 3rd party features: Login Location Fix +login_location_fix: + fix_portal: '&a你在登录时卡在了地狱门, 现已修正' + fix_underground: '&a你被埋住了, 坐标已修正, 下次下线之前请小心!' + cannot_fix_underground: '&a你被埋住了, 坐标无法修正, 只好送你去了最高点, 自求多福吧少年~'