Fixed players being able to add color codes in names and be shown on console (on kick)

This commit is contained in:
Shoghi Cervantes
2014-04-05 14:02:35 +02:00
parent 7be9ea68c7
commit 1a8cbdd6c7
2 changed files with 10 additions and 5 deletions

View File

@ -1262,7 +1262,8 @@ class Player extends Human implements CommandSender, IPlayer{
if($this->loggedIn === true){
break;
}
$this->username = $packet->username;
$this->username = TextFormat::clean($packet->username);
$this->displayName = $this->username;
$this->iusername = strtolower($this->username);
$this->loginData = array("clientId" => $packet->clientId, "loginData" => $packet->loginData);
@ -1286,7 +1287,7 @@ class Player extends Human implements CommandSender, IPlayer{
return;
}
if(preg_match('#^[a-zA-Z0-9_]{3,16}$#', $this->username) == 0 or $this->username === "" or $this->iusername === "rcon" or $this->iusername === "console"){
if(preg_match('#^[a-zA-Z0-9_]{3,16}$#', $packet->username) == 0 or $this->username === "" or $this->iusername === "rcon" or $this->iusername === "console"){
$this->close("", "Bad username");
return;