bad fix for WritableBook phpstan warning

master has this shit so much better
This commit is contained in:
Dylan K. Taylor 2019-12-04 22:00:19 +00:00
parent 39c607cbd5
commit 8ecf5e02b9

View File

@ -186,16 +186,18 @@ class WritableBook extends Item{
* @return CompoundTag[]
*/
public function getPages() : array{
$pages = $this->getNamedTag()->getListTag(self::TAG_PAGES);
if($pages === null){
return [];
}
/** @var CompoundTag[] $pages */
$pages = $this->getPagesTag()->getValue();
return $pages->getValue();
return $pages;
}
protected function getPagesTag() : ListTag{
return $this->getNamedTag()->getListTag(self::TAG_PAGES) ?? new ListTag(self::TAG_PAGES, [], NBT::TAG_Compound);
$pagesTag = $this->getNamedTag()->getListTag(self::TAG_PAGES);
if($pagesTag !== null and $pagesTag->getTagType() === NBT::TAG_Compound){
return $pagesTag;
}
return new ListTag(self::TAG_PAGES, [], NBT::TAG_Compound);
}
/**