mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-12 16:59:44 +00:00
Player: remove removeFormat, chat formatting is now unconditionally available
This change was made after exploring turning this into a permission. It occurred to me that this feature is entirely superfluous because it's non-vanilla, can be done by plugins, and is usually considered as a bug. In addition, disabling this behaviour required third party code just for this one thing because it was not able to be managed by a permissions plugin. Instead, it's better to produce a plugin which implements this behaviour if it's desired, by making use of SignChangeEvent and PlayerChatEvent/PlayerCommandPreprocessEvent. close #3856, close #2288
This commit is contained in:
parent
e39d2c4621
commit
78bddac823
@ -105,9 +105,8 @@ abstract class BaseSign extends Transparent{
|
||||
if($size > 1000){
|
||||
throw new \UnexpectedValueException($author->getName() . " tried to write $size bytes of text onto a sign (bigger than max 1000)");
|
||||
}
|
||||
$removeFormat = $author->getRemoveFormat();
|
||||
$ev = new SignChangeEvent($this, $author, new SignText(array_map(function(string $line) use ($removeFormat) : string{
|
||||
return TextFormat::clean($line, $removeFormat);
|
||||
$ev = new SignChangeEvent($this, $author, new SignText(array_map(function(string $line) : string{
|
||||
return TextFormat::clean($line, false);
|
||||
}, $text->getLines())));
|
||||
$ev->call();
|
||||
if(!$ev->isCancelled()){
|
||||
|
@ -183,8 +183,6 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
|
||||
/** @var int */
|
||||
protected $messageCounter = 2;
|
||||
/** @var bool */
|
||||
protected $removeFormat = true;
|
||||
|
||||
/** @var int */
|
||||
protected $firstPlayed;
|
||||
@ -345,9 +343,6 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
}
|
||||
|
||||
$this->keepMovement = true;
|
||||
if($this->isOp()){
|
||||
$this->setRemoveFormat(false);
|
||||
}
|
||||
|
||||
$this->setNameTagVisible();
|
||||
$this->setNameTagAlwaysVisible();
|
||||
@ -485,14 +480,6 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
return $this->server;
|
||||
}
|
||||
|
||||
public function getRemoveFormat() : bool{
|
||||
return $this->removeFormat;
|
||||
}
|
||||
|
||||
public function setRemoveFormat(bool $remove = true) : void{
|
||||
$this->removeFormat = $remove;
|
||||
}
|
||||
|
||||
public function getScreenLineHeight() : int{
|
||||
return $this->lineHeight ?? 7;
|
||||
}
|
||||
@ -1370,7 +1357,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
public function chat(string $message) : bool{
|
||||
$this->doCloseInventory();
|
||||
|
||||
$message = TextFormat::clean($message, $this->removeFormat);
|
||||
$message = TextFormat::clean($message, false);
|
||||
foreach(explode("\n", $message) as $messagePart){
|
||||
if(trim($messagePart) !== "" and strlen($messagePart) <= 255 and $this->messageCounter-- > 0){
|
||||
if(strpos($messagePart, './') === 0){
|
||||
|
Loading…
x
Reference in New Issue
Block a user