Fix code style
This commit is contained in:
parent
7301a22d44
commit
0c10cb0ead
@ -121,7 +121,9 @@ public class Messages {
|
||||
* @return The message from the file
|
||||
*/
|
||||
private String retrieveMessage(MessageKey key, CommandSender sender) {
|
||||
String locale = I18NUtils.getLocale(sender);
|
||||
String locale = sender instanceof Player
|
||||
? I18NUtils.getLocale((Player) sender)
|
||||
: null;
|
||||
String message = messagesFileHandler.getMessageByLocale(key.getKey(), locale);
|
||||
String displayName = sender.getName();
|
||||
if (sender instanceof Player) {
|
||||
|
||||
@ -3,7 +3,6 @@ package fr.xephi.authme.util.message;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@ -29,27 +28,21 @@ public class I18NUtils {
|
||||
/**
|
||||
* Returns the locale that player uses.
|
||||
*
|
||||
* @param sender The player
|
||||
* @param player The player
|
||||
*/
|
||||
public static String getLocale(CommandSender sender) {
|
||||
String locale = null;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
public static String getLocale(Player player) {
|
||||
if (Utils.majorVersion >= 12) {
|
||||
locale = player.getLocale().toLowerCase();
|
||||
return player.getLocale().toLowerCase();
|
||||
} else {
|
||||
try {
|
||||
Object spigot = spigotMethod.invoke(player);
|
||||
|
||||
Method spigotGetLocaleMethod = spigot.getClass().getMethod("getLocale");
|
||||
locale = ((String) spigotGetLocaleMethod.invoke(spigot)).toLowerCase();
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return locale;
|
||||
return ((String) spigotGetLocaleMethod.invoke(spigot)).toLowerCase();
|
||||
} catch (Exception ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user