From 226175f96156c216f1380c160d29a36f3ec3b073 Mon Sep 17 00:00:00 2001 From: "Tim (robske_110)" Date: Fri, 1 Sep 2017 09:34:40 +0200 Subject: [PATCH] setText now nullable instead of overwriting with empty lines (#1204) --- src/pocketmine/tile/Sign.php | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/pocketmine/tile/Sign.php b/src/pocketmine/tile/Sign.php index 49688588a..fc90ed2ed 100644 --- a/src/pocketmine/tile/Sign.php +++ b/src/pocketmine/tile/Sign.php @@ -54,11 +54,30 @@ class Sign extends Spawnable{ unset($this->namedtag->Creator); } + /** + * Changes contents of the specific lines to the string provided. + * Leaves contents of the specifc lines as is if null is provided. + * + * @param null|string $line1 + * @param null|string $line2 + * @param null|string $line3 + * @param null|string $line4 + * + * @return bool + */ public function setText($line1 = "", $line2 = "", $line3 = "", $line4 = ""){ - $this->namedtag->Text1->setValue($line1); - $this->namedtag->Text2->setValue($line2); - $this->namedtag->Text3->setValue($line3); - $this->namedtag->Text4->setValue($line4); + if($line1 !== null){ + $this->namedtag->Text1->setValue("Text1", $line1); + } + if($line2 !== null){ + $this->namedtag->Text2->setValue("Text2", $line2); + } + if($line3 !== null){ + $this->namedtag->Text3->setValue("Text3", $line3); + } + if($line4 !== null){ + $this->namedtag->Text4->setValue("Text4", $line4); + } $this->onChanged(); }