setText now nullable instead of overwriting with empty lines (#1204)

This commit is contained in:
Tim (robske_110) 2017-09-01 09:34:40 +02:00 committed by Dylan K. Taylor
parent 297cfcf168
commit 226175f961

View File

@ -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();
}