mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 19:02:59 +00:00
Item->getNamedTag() now always returns a CompoundTag object, removed lots of boilerplate code
This change resulted from many complaints and ugly boilerplate code because getNamedTag() is only ever used when you want to read from the tag or modify it. If you have code that depends on this returning null, you should use hasCompoundTag() instead.
This commit is contained in:
@ -63,7 +63,7 @@ class WrittenBook extends WritableBook{
|
||||
if($generation < 0 or $generation > 3){
|
||||
throw new \InvalidArgumentException("Generation \"$generation\" is out of range");
|
||||
}
|
||||
$namedTag = $this->getCorrectedNamedTag();
|
||||
$namedTag = $this->getNamedTag();
|
||||
|
||||
if(isset($namedTag->generation)){
|
||||
$namedTag->generation->setValue($generation);
|
||||
@ -93,7 +93,7 @@ class WrittenBook extends WritableBook{
|
||||
* @param string $authorName
|
||||
*/
|
||||
public function setAuthor(string $authorName) : void{
|
||||
$namedTag = $this->getCorrectedNamedTag();
|
||||
$namedTag = $this->getNamedTag();
|
||||
if(isset($namedTag->author)){
|
||||
$namedTag->author->setValue($authorName);
|
||||
}else{
|
||||
@ -120,7 +120,7 @@ class WrittenBook extends WritableBook{
|
||||
* @param string $title
|
||||
*/
|
||||
public function setTitle(string $title) : void{
|
||||
$namedTag = $this->getCorrectedNamedTag();
|
||||
$namedTag = $this->getNamedTag();
|
||||
if(isset($namedTag->title)){
|
||||
$namedTag->title->setValue($title);
|
||||
}else{
|
||||
|
Reference in New Issue
Block a user