Instantly return null if didn't receive locale packet before calling messages sending method

This commit is contained in:
Dreeam 2024-06-03 20:04:54 +08:00
parent e922422922
commit fbf5f32415
No known key found for this signature in database
GPG Key ID: 0998F8AFD8F667AB

View File

@ -45,18 +45,11 @@ public class I18NUtils {
public static String getLocale(Player player) {
if (Utils.MAJOR_VERSION > 15) {
return player.getLocale().toLowerCase();
} else {
long startTime = System.currentTimeMillis();
for (;;) {
if (PLAYER_LOCALE.containsKey(player.getUniqueId())) {
return PLAYER_LOCALE.get(player.getUniqueId());
}
if (System.currentTimeMillis() - startTime > 500) {
return null;
}
}
} else if (PLAYER_LOCALE.containsKey(player.getUniqueId())) {
return PLAYER_LOCALE.get(player.getUniqueId());
}
return null;
}
public static void addLocale(UUID uuid, String locale) {