geforkt von SteamWar/BungeeCore
Add locale locking
Dieser Commit ist enthalten in:
Ursprung
092efd7063
Commit
df24f2685a
@ -1 +1 @@
|
||||
Subproject commit e83103d8afce8161a12d008d6ad99ba439243b27
|
||||
Subproject commit 0f03b57e437c1d843816b7202d95b79ff0a8d2df
|
@ -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
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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<Mod> 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<BaseComponent[]> disconnect, List<Mod> mods){
|
||||
|
@ -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<ProxiedPlayer> 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
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren