getNamedTag()->getInt(self::TAG_GENERATION, -1); } /** * Sets the generation of a book. * * @param int $generation */ public function setGeneration(int $generation) : void{ if($generation < 0 or $generation > 3){ throw new \InvalidArgumentException("Generation \"$generation\" is out of range"); } $namedTag = $this->getNamedTag(); $namedTag->setInt(self::TAG_GENERATION, $generation); $this->setNamedTag($namedTag); } /** * Returns the author of this book. * This is not a reliable way to get the name of the player who signed this book. * The author can be set to anything when signing a book. * * @return string */ public function getAuthor() : string{ return $this->getNamedTag()->getString(self::TAG_AUTHOR, ""); } /** * Sets the author of this book. * * @param string $authorName */ public function setAuthor(string $authorName) : void{ $namedTag = $this->getNamedTag(); $namedTag->setString(self::TAG_AUTHOR, $authorName); $this->setNamedTag($namedTag); } /** * Returns the title of this book. * * @return string */ public function getTitle() : string{ return $this->getNamedTag()->getString(self::TAG_TITLE, ""); } /** * Sets the author of this book. * * @param string $title */ public function setTitle(string $title) : void{ $namedTag = $this->getNamedTag(); $namedTag->setString(self::TAG_TITLE, $title); $this->setNamedTag($namedTag); } }