|
48 | 48 | import com.velocitypowered.api.util.GameProfile; |
49 | 49 | import com.velocitypowered.api.util.ModInfo; |
50 | 50 | import com.velocitypowered.proxy.VelocityServer; |
51 | | -import com.velocitypowered.proxy.config.VelocityConfiguration; |
52 | 51 | import com.velocitypowered.proxy.connection.MinecraftConnection; |
53 | 52 | import com.velocitypowered.proxy.connection.MinecraftConnectionAssociation; |
54 | 53 | import com.velocitypowered.proxy.connection.backend.VelocityServerConnection; |
|
79 | 78 | import java.util.Collections; |
80 | 79 | import java.util.List; |
81 | 80 | import java.util.Locale; |
82 | | -import java.util.Objects; |
83 | 81 | import java.util.Optional; |
84 | 82 | import java.util.Queue; |
85 | 83 | import java.util.UUID; |
|
97 | 95 | import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; |
98 | 96 | import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; |
99 | 97 | import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer; |
100 | | -import net.kyori.adventure.title.Title; |
101 | | -import net.kyori.adventure.title.Title.Times; |
102 | 98 | import net.kyori.adventure.translation.GlobalTranslator; |
103 | 99 | import org.apache.logging.log4j.LogManager; |
104 | 100 | import org.apache.logging.log4j.Logger; |
@@ -149,6 +145,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { |
149 | 145 | .withStatic(PermissionChecker.POINTER, getPermissionChecker()) |
150 | 146 | .build(); |
151 | 147 | private @Nullable String clientBrand; |
| 148 | + private @Nullable Locale effectiveLocale; |
152 | 149 |
|
153 | 150 | ConnectedPlayer(VelocityServer server, GameProfile profile, MinecraftConnection connection, |
154 | 151 | @Nullable InetSocketAddress virtualHost, boolean onlineMode) { |
@@ -178,6 +175,19 @@ public String getUsername() { |
178 | 175 | return profile.getName(); |
179 | 176 | } |
180 | 177 |
|
| 178 | + @Override |
| 179 | + public Locale getEffectiveLocale() { |
| 180 | + if (effectiveLocale == null && settings != null) { |
| 181 | + return settings.getLocale(); |
| 182 | + } |
| 183 | + return effectiveLocale; |
| 184 | + } |
| 185 | + |
| 186 | + @Override |
| 187 | + public void setEffectiveLocale(Locale locale) { |
| 188 | + effectiveLocale = locale; |
| 189 | + } |
| 190 | + |
181 | 191 | @Override |
182 | 192 | public UUID getUniqueId() { |
183 | 193 | return profile.getId(); |
@@ -276,7 +286,7 @@ public ProtocolVersion getProtocolVersion() { |
276 | 286 | */ |
277 | 287 | public Component translateMessage(Component message) { |
278 | 288 | Locale locale = ClosestLocaleMatcher.INSTANCE |
279 | | - .lookupClosest(this.settings == null ? Locale.getDefault() : this.settings.getLocale()); |
| 289 | + .lookupClosest(getEffectiveLocale() == null ? Locale.getDefault() : getEffectiveLocale()); |
280 | 290 | return GlobalTranslator.render(message, locale); |
281 | 291 | } |
282 | 292 |
|
|
0 commit comments