From 78bddac823d4ac519e9b35d1418a9482607b785c Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 6 Oct 2020 14:00:23 +0100 Subject: [PATCH] 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 --- src/block/BaseSign.php | 5 ++--- src/player/Player.php | 15 +-------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/block/BaseSign.php b/src/block/BaseSign.php index a1d2d6944..1709e4a8a 100644 --- a/src/block/BaseSign.php +++ b/src/block/BaseSign.php @@ -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()){ diff --git a/src/player/Player.php b/src/player/Player.php index fd9d64800..5b8cd628e 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -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){