Localized LoginLocationFix

This commit is contained in:
HaHaWTH 2023-11-12 14:12:11 +08:00
parent e69ba501da
commit eed5ce1b7b
5 changed files with 36 additions and 3 deletions

View File

@ -2,6 +2,8 @@ package fr.xephi.authme.listener;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.api.v3.AuthMeApi; 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.settings.properties.SecuritySettings;
import fr.xephi.authme.util.TeleportUtils; import fr.xephi.authme.util.TeleportUtils;
import org.bukkit.Location; import org.bukkit.Location;
@ -20,6 +22,8 @@ import javax.inject.Inject;
public class LoginLocationFixListener implements Listener { public class LoginLocationFixListener implements Listener {
@Inject @Inject
private AuthMe plugin; private AuthMe plugin;
@Inject
private Messages messages;
private final AuthMeApi authmeApi = AuthMeApi.getInstance(); private final AuthMeApi authmeApi = AuthMeApi.getInstance();
public LoginLocationFixListener() { public LoginLocationFixListener() {
@ -65,7 +69,7 @@ public class LoginLocationFixListener implements Listener {
JoinBlock.getRelative(BlockFace.UP).breakNaturally(); JoinBlock.getRelative(BlockFace.UP).breakNaturally();
JoinBlock.breakNaturally(); JoinBlock.breakNaturally();
} }
player.sendMessage("§a你在登录时卡在了地狱门, 现已修正"); messages.send(player, MessageKey.LOCATION_FIX_PORTAL);
} else if (isFixGroundStuck) { } else if (isFixGroundStuck) {
Material UpType = JoinLocation.getBlock().getRelative(BlockFace.UP).getType(); Material UpType = JoinLocation.getBlock().getRelative(BlockFace.UP).getType();
World world = player.getWorld(); World world = player.getWorld();
@ -88,7 +92,7 @@ public class LoginLocationFixListener implements Listener {
} else { } else {
player.teleport(JoinBlock.getLocation().add(0.5, 0.1, 0.5)); player.teleport(JoinBlock.getLocation().add(0.5, 0.1, 0.5));
} }
player.sendMessage("§a你被埋住了, 坐标已修正, 下次下线之前请小心!"); messages.send(player, MessageKey.LOCATION_FIX_UNDERGROUND);
break; break;
} }
if (i == MaxHeight) { if (i == MaxHeight) {
@ -97,7 +101,7 @@ public class LoginLocationFixListener implements Listener {
} else { } else {
player.teleport(JoinBlock.getLocation().add(0.5, 1.1, 0.5)); player.teleport(JoinBlock.getLocation().add(0.5, 1.1, 0.5));
} }
player.sendMessage("§a你被埋住了, 坐标无法修正, 只好送你去了最高点, 自求多福吧少年~"); messages.send(player, MessageKey.LOCATION_FIX_UNDERGROUND_CANT_FIX);
} }
} }
} }

View File

@ -4,6 +4,22 @@ package fr.xephi.authme.message;
* Keys for translatable messages managed by {@link Messages}. * Keys for translatable messages managed by {@link Messages}.
*/ */
public enum MessageKey { 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! * Bedrock auto login success!
*/ */

View File

@ -151,6 +151,7 @@ public class MessageUpdater {
.put("two_factor", "Two-factor authentication") .put("two_factor", "Two-factor authentication")
.put("gui_captcha", "3rd party features: GUI Captcha") .put("gui_captcha", "3rd party features: GUI Captcha")
.put("bedrock_auto_login", "3rd party features: Bedrock Auto Login") .put("bedrock_auto_login", "3rd party features: Bedrock Auto Login")
.put("login_location_fix", "3rd party features: Login Location Fix")
.build(); .build();
Set<String> addedKeys = new HashSet<>(); Set<String> addedKeys = new HashSet<>();

View File

@ -170,3 +170,9 @@ gui_captcha:
# 3rd party features: Bedrock Auto Login # 3rd party features: Bedrock Auto Login
bedrock_auto_login: bedrock_auto_login:
success: '&aBedrock auto login success!' 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.'

View File

@ -179,3 +179,9 @@ gui_captcha:
# 3rd party features: Bedrock Auto Login # 3rd party features: Bedrock Auto Login
bedrock_auto_login: bedrock_auto_login:
success: "&a基岩版自动登录完成" success: "&a基岩版自动登录完成"
# 3rd party features: Login Location Fix
login_location_fix:
fix_portal: '&a你在登录时卡在了地狱门, 现已修正'
fix_underground: '&a你被埋住了, 坐标已修正, 下次下线之前请小心!'
cannot_fix_underground: '&a你被埋住了, 坐标无法修正, 只好送你去了最高点, 自求多福吧少年~'