diff --git a/CommonCore b/CommonCore index e83103d..0f03b57 160000 --- a/CommonCore +++ b/CommonCore @@ -1 +1 @@ -Subproject commit e83103d8afce8161a12d008d6ad99ba439243b27 +Subproject commit 0f03b57e437c1d843816b7202d95b79ff0a8d2df diff --git a/src/de/steamwar/bungeecore/Message.java b/src/de/steamwar/bungeecore/Message.java index 1f1213f..5ceba7d 100644 --- a/src/de/steamwar/bungeecore/Message.java +++ b/src/de/steamwar/bungeecore/Message.java @@ -57,7 +57,7 @@ public class Message { @Deprecated private static Locale locale(CommandSender sender) { - return sender instanceof ProxiedPlayer ? ((ProxiedPlayer)sender).getLocale() : Locale.getDefault(); + return sender instanceof ProxiedPlayer ? ChatSender.getLocale((ProxiedPlayer)sender) : Locale.getDefault(); } @Deprecated diff --git a/src/de/steamwar/bungeecore/commands/LockCurrentLocaleCommand.java b/src/de/steamwar/bungeecore/commands/LockCurrentLocaleCommand.java index 60daf4c..cffc5be 100644 --- a/src/de/steamwar/bungeecore/commands/LockCurrentLocaleCommand.java +++ b/src/de/steamwar/bungeecore/commands/LockCurrentLocaleCommand.java @@ -24,6 +24,8 @@ import de.steamwar.bungeecore.sql.UserConfig; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.connection.ProxiedPlayer; +import java.util.Locale; + public class LockCurrentLocaleCommand extends BasicCommand { public LockCurrentLocaleCommand() { @@ -39,6 +41,11 @@ public class LockCurrentLocaleCommand extends BasicCommand { SteamwarUser steamwarUser = SteamwarUser.get(proxiedPlayer); // TODO: Hier fehlt noch eine Nachricht an den User. Sollte deswegen erst gemerged werden, wenn der branch 'english' germerged ist + Locale locale = proxiedPlayer.getLocale(); + if (locale == null) { + // TODO: Fehlermeldung + return; + } UserConfig.updatePlayerConfig(steamwarUser.getId(), "language", proxiedPlayer.getLocale().getLanguage()); } } diff --git a/src/de/steamwar/bungeecore/listeners/mods/Utils.java b/src/de/steamwar/bungeecore/listeners/mods/Utils.java index 7e3e4cc..155e1b2 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Utils.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Utils.java @@ -25,6 +25,7 @@ import de.steamwar.bungeecore.sql.Mod; import de.steamwar.bungeecore.sql.Mod.ModType; import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.messages.ChatSender; import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -62,7 +63,7 @@ class Utils { } static boolean handleMods(ProxiedPlayer player, List mods) { - return handleMods(player.getUniqueId(), player.getLocale(), player::disconnect, mods); + return handleMods(player.getUniqueId(), ChatSender.getLocale(player), player::disconnect, mods); } static boolean handleMods(UUID uuid, Locale locale, Consumer disconnect, List mods){ diff --git a/src/de/steamwar/messages/ChatSender.java b/src/de/steamwar/messages/ChatSender.java index a5a3384..674290a 100644 --- a/src/de/steamwar/messages/ChatSender.java +++ b/src/de/steamwar/messages/ChatSender.java @@ -46,6 +46,17 @@ import java.util.stream.Stream; public interface ChatSender { + static Locale getLocale(ProxiedPlayer player) { + String dbLocale = UserConfig.getConfig(SteamwarUser.get(player).getId(), "language"); + if (dbLocale != null) { + return new Locale(dbLocale); + } + Locale locale = player.getLocale(); + if(locale == null) + locale = Locale.getDefault(); + return locale; + } + static Stream all() { return ProxyServer.getInstance().getPlayers().stream(); } @@ -151,13 +162,7 @@ public interface ChatSender { @Override public Locale getLocale() { - String dbLocale = UserConfig.getConfig(user().getId(), "language"); - if (dbLocale != null) - return new Locale(dbLocale); - Locale locale = player.getLocale(); - if(locale == null) - locale = Locale.getDefault(); - return locale; + return ChatSender.getLocale(player); } @Override