mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-11 05:55:33 +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 */
|
/** @var int|null */
|
||||||
protected $lineHeight = null;
|
protected $lineHeight = null;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
protected $locale = "en_US";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return TranslationContainer|string
|
* @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.
|
* Called when a player changes their skin.
|
||||||
* Plugin developers should not use this, use setSkin() and sendSkin() instead.
|
* 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->displayName = $this->username;
|
||||||
$this->iusername = strtolower($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)){
|
if(count($this->server->getOnlinePlayers()) >= $this->server->getMaxPlayers() and $this->kick("disconnectionScreen.serverFull", false)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,8 @@ class LoginPacket extends DataPacket{
|
|||||||
public $identityPublicKey;
|
public $identityPublicKey;
|
||||||
/** @var string */
|
/** @var string */
|
||||||
public $serverAddress;
|
public $serverAddress;
|
||||||
|
/** @var string */
|
||||||
|
public $locale;
|
||||||
|
|
||||||
/** @var array (the "chain" index contains one or more JWTs) */
|
/** @var array (the "chain" index contains one or more JWTs) */
|
||||||
public $chainData = [];
|
public $chainData = [];
|
||||||
@ -119,6 +121,8 @@ class LoginPacket extends DataPacket{
|
|||||||
|
|
||||||
$this->clientId = $this->clientData["ClientRandomId"] ?? null;
|
$this->clientId = $this->clientData["ClientRandomId"] ?? null;
|
||||||
$this->serverAddress = $this->clientData["ServerAddress"] ?? null;
|
$this->serverAddress = $this->clientData["ServerAddress"] ?? null;
|
||||||
|
|
||||||
|
$this->locale = $this->clientData["LanguageCode"] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function encodePayload(){
|
protected function encodePayload(){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user