mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-23 00:55:57 +00:00
added API to get player language code
sadly this isn't particularly useful without something like the intl extension to translate the language codes to ISO-632-1 codes like the ones PocketMine-MP uses. However, this will do for now.
This commit is contained in:
parent
2ec7763bd6
commit
6ccb494f8d
@ -297,6 +297,9 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
/** @var int|null */
|
||||
protected $lineHeight = null;
|
||||
|
||||
/** @var string */
|
||||
protected $locale = "en_US";
|
||||
|
||||
/**
|
||||
* @return TranslationContainer|string
|
||||
*/
|
||||
@ -738,6 +741,14 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the player's locale, e.g. en_US.
|
||||
* @return string
|
||||
*/
|
||||
public function getLocale() : string{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player changes their skin.
|
||||
* Plugin developers should not use this, use setSkin() and sendSkin() instead.
|
||||
@ -1992,6 +2003,10 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
$this->displayName = $this->username;
|
||||
$this->iusername = strtolower($this->username);
|
||||
|
||||
if($packet->locale !== null){
|
||||
$this->locale = $packet->locale;
|
||||
}
|
||||
|
||||
if(count($this->server->getOnlinePlayers()) >= $this->server->getMaxPlayers() and $this->kick("disconnectionScreen.serverFull", false)){
|
||||
return true;
|
||||
}
|
||||
|
@ -50,6 +50,8 @@ class LoginPacket extends DataPacket{
|
||||
public $identityPublicKey;
|
||||
/** @var string */
|
||||
public $serverAddress;
|
||||
/** @var string */
|
||||
public $locale;
|
||||
|
||||
/** @var array (the "chain" index contains one or more JWTs) */
|
||||
public $chainData = [];
|
||||
@ -119,6 +121,8 @@ class LoginPacket extends DataPacket{
|
||||
|
||||
$this->clientId = $this->clientData["ClientRandomId"] ?? null;
|
||||
$this->serverAddress = $this->clientData["ServerAddress"] ?? null;
|
||||
|
||||
$this->locale = $this->clientData["LanguageCode"] ?? null;
|
||||
}
|
||||
|
||||
protected function encodePayload(){
|
||||
|
Loading…
x
Reference in New Issue
Block a user