mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-04 00:55:14 +00:00
Improve usability of Sign API (#1202)
* Improve usability of Sign API * PHP * Throw exceptions if out of range * Fix phpdocs * Formatting, additional checks in the SignChangeEvent. * Blame php storm * require line count to always be 4 * Adjust exception message
This commit is contained in:
committed by
Dylan K. Taylor
parent
cca9cf2c86
commit
42fb1d1fef
@ -64,6 +64,33 @@ class Sign extends Spawnable{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $index 0-3
|
||||
* @param string $line
|
||||
* @param bool $update
|
||||
*/
|
||||
public function setLine(int $index, string $line, bool $update = true){
|
||||
if($index < 0 or $index > 3){
|
||||
throw new \InvalidArgumentException("Index must be in the range 0-3!");
|
||||
}
|
||||
$this->namedtag["Text" . ($index + 1)] = $line;
|
||||
if($update){
|
||||
$this->onChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $index 0-3
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLine(int $index) : string{
|
||||
if($index < 0 or $index > 3){
|
||||
throw new \InvalidArgumentException("Index must be in the range 0-3!");
|
||||
}
|
||||
return (string) $this->namedtag["Text" . ($index + 1)];
|
||||
}
|
||||
|
||||
public function getText(){
|
||||
return [
|
||||
|
Reference in New Issue
Block a user