Fixed sub-optimal code in WritableBook

This commit is contained in:
Dylan K. Taylor 2017-10-15 10:14:02 +01:00
parent cdebb62c35
commit a547e2cca8

View File

@ -181,11 +181,11 @@ class WritableBook extends Item{
* @return bool * @return bool
*/ */
private function pushPages(int $pageId, CompoundTag $namedTag, bool $downwards = true) : bool{ private function pushPages(int $pageId, CompoundTag $namedTag, bool $downwards = true) : bool{
if(empty($this->getPages())){ $pages = $this->getPages();
if(empty($pages)){
return false; return false;
} }
$pages = $this->getPages();
$type = $downwards ? -1 : 1; $type = $downwards ? -1 : 1;
foreach($pages as $key => $page){ foreach($pages as $key => $page){
if(($key <= $pageId and $downwards) or ($key < $pageId and !$downwards)){ if(($key <= $pageId and $downwards) or ($key < $pageId and !$downwards)){