Add method to get player's locale

This commit is contained in:
md_5 2014-06-11 16:03:00 +10:00
parent 3c938c03c7
commit 91989564e5
2 changed files with 16 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package net.md_5.bungee.api.connection; package net.md_5.bungee.api.connection;
import java.util.Locale;
import net.md_5.bungee.api.Callback; import net.md_5.bungee.api.Callback;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.config.ServerInfo;
@ -133,4 +134,11 @@ public interface ProxiedPlayer extends Connection, CommandSender
* @return the UUID * @return the UUID
*/ */
UUID getUniqueId(); UUID getUniqueId();
/**
* Gets this player's locale.
*
* @return the locale
*/
Locale getLocale();
} }

View File

@ -13,6 +13,7 @@ import java.net.InetSocketAddress;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Locale;
import java.util.Objects; import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;
@ -105,6 +106,7 @@ public final class UserConnection implements ProxiedPlayer
private String displayName; private String displayName;
@Getter @Getter
private EntityMap entityRewrite; private EntityMap entityRewrite;
private Locale locale;
/*========================================================================*/ /*========================================================================*/
private final Unsafe unsafe = new Unsafe() private final Unsafe unsafe = new Unsafe()
{ {
@ -429,4 +431,10 @@ public final class UserConnection implements ProxiedPlayer
{ {
return getPendingConnection().getUniqueId(); return getPendingConnection().getUniqueId();
} }
@Override
public Locale getLocale()
{
return ( locale == null ) ? locale = Locale.forLanguageTag( settings.getLocale() ) : locale;
}
} }