mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-27 21:59:52 +00:00
Added Player::getRemoveFormat() and Player::setRemoveFormat(bool) to choose showing colors in chat and nametags
This commit is contained in:
parent
79bc42c995
commit
3bd33a129f
@ -132,6 +132,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
protected $connected = true;
|
||||
protected $clientID;
|
||||
protected $ip;
|
||||
protected $removeFormat = true;
|
||||
protected $port;
|
||||
protected $username;
|
||||
protected $iusername;
|
||||
@ -228,6 +229,20 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
return $this->server;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getRemoveFormat(){
|
||||
return $this->removeFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $remove
|
||||
*/
|
||||
public function setRemoveFormat($remove = true){
|
||||
$this->removeFormat = (bool) $remove;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
*
|
||||
@ -424,10 +439,16 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$this->displayName = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNameTag(){
|
||||
return $this->nameTag;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setNameTag($name){
|
||||
$this->nameTag = $name;
|
||||
$this->despawnFromAll();
|
||||
@ -1979,7 +2000,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
if($m !== ""){
|
||||
$pk = new MessagePacket;
|
||||
$pk->author = ""; //Do not use this ;)
|
||||
$pk->message = TextFormat::clean($m); //Colors not implemented :(
|
||||
$pk->message = $this->removeFormat === false ? $m : TextFormat::clean($m);
|
||||
$this->dataPacket($pk);
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ use pocketmine\network\protocol\AddPlayerPacket;
|
||||
use pocketmine\network\protocol\RemovePlayerPacket;
|
||||
use pocketmine\network\protocol\SetEntityMotionPacket;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\utils\TextFormat;
|
||||
|
||||
class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
|
||||
@ -135,7 +136,11 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
||||
|
||||
$pk = new AddPlayerPacket;
|
||||
$pk->clientID = 0;
|
||||
$pk->username = $this->nameTag;
|
||||
if($player->getRemoveFormat()){
|
||||
$pk->username = TextFormat::clean($this->nameTag);
|
||||
}else{
|
||||
$pk->username = $this->nameTag;
|
||||
}
|
||||
$pk->eid = $this->getID();
|
||||
$pk->x = $this->x;
|
||||
$pk->y = $this->y;
|
||||
|
Loading…
x
Reference in New Issue
Block a user