mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-04 00:55:14 +00:00
Item: simplify equals()
getNamedTag() can't return null anymore.
This commit is contained in:
@ -704,18 +704,9 @@ class Item implements ItemIds, \JsonSerializable{
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
final public function equals(Item $item, bool $checkDamage = true, bool $checkCompound = true) : bool{
|
final public function equals(Item $item, bool $checkDamage = true, bool $checkCompound = true) : bool{
|
||||||
if($this->id === $item->getId() and (!$checkDamage or $this->getMeta() === $item->getMeta())){
|
return $this->id === $item->getId() and
|
||||||
if($checkCompound){
|
(!$checkDamage or $this->getMeta() === $item->getMeta()) and
|
||||||
$tag1 = $this->getNamedTag();
|
(!$checkCompound or $this->getNamedTag()->equals($item->getNamedTag()));
|
||||||
$tag2 = $item->getNamedTag();
|
|
||||||
|
|
||||||
return ($tag1 === null and $tag2 === null) or ($tag1 !== null and $tag2 !== null and $tag1->equals($tag2));
|
|
||||||
}else{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user