mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
add return typehints for Item fluent methods
to prevent issues like a2d4baf8b98223839918081cd8a5981fd7bff05d happening again >.>
This commit is contained in:
parent
0621d5c8ea
commit
733e61f815
@ -215,9 +215,9 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
*
|
||||
* @param CompoundTag|string $tags
|
||||
*
|
||||
* @return $this
|
||||
* @return Item
|
||||
*/
|
||||
public function setCompoundTag($tags){
|
||||
public function setCompoundTag($tags) : Item{
|
||||
if($tags instanceof CompoundTag){
|
||||
$this->setNamedTag($tags);
|
||||
}else{
|
||||
@ -259,9 +259,9 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
/**
|
||||
* @param CompoundTag $compound
|
||||
*
|
||||
* @return $this
|
||||
* @return Item
|
||||
*/
|
||||
public function setCustomBlockData(CompoundTag $compound){
|
||||
public function setCustomBlockData(CompoundTag $compound) : Item{
|
||||
$tags = clone $compound;
|
||||
$tags->setName(self::TAG_BLOCK_ENTITY_TAG);
|
||||
$this->setNamedTagEntry($tags);
|
||||
@ -438,9 +438,9 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return $this
|
||||
* @return Item
|
||||
*/
|
||||
public function setCustomName(string $name){
|
||||
public function setCustomName(string $name) : Item{
|
||||
if($name === ""){
|
||||
$this->clearCustomName();
|
||||
}
|
||||
@ -458,9 +458,9 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
* @return Item
|
||||
*/
|
||||
public function clearCustomName(){
|
||||
public function clearCustomName() : Item{
|
||||
$display = $this->getNamedTagEntry(self::TAG_DISPLAY);
|
||||
if($display instanceof CompoundTag){
|
||||
$display->removeTag(self::TAG_DISPLAY_NAME);
|
||||
@ -492,9 +492,9 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
/**
|
||||
* @param string[] $lines
|
||||
*
|
||||
* @return $this
|
||||
* @return Item
|
||||
*/
|
||||
public function setLore(array $lines){
|
||||
public function setLore(array $lines) : Item{
|
||||
$display = $this->getNamedTagEntry(self::TAG_DISPLAY);
|
||||
if(!($display instanceof CompoundTag)){
|
||||
$display = new CompoundTag(self::TAG_DISPLAY, []);
|
||||
@ -547,9 +547,9 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
* Sets the Item's NBT from the supplied CompoundTag object.
|
||||
* @param CompoundTag $tag
|
||||
*
|
||||
* @return $this
|
||||
* @return Item
|
||||
*/
|
||||
public function setNamedTag(CompoundTag $tag){
|
||||
public function setNamedTag(CompoundTag $tag) : Item{
|
||||
if($tag->getCount() === 0){
|
||||
return $this->clearNamedTag();
|
||||
}
|
||||
@ -564,7 +564,7 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
* Removes the Item's NBT.
|
||||
* @return Item
|
||||
*/
|
||||
public function clearNamedTag(){
|
||||
public function clearNamedTag() : Item{
|
||||
return $this->setCompoundTag("");
|
||||
}
|
||||
|
||||
@ -577,9 +577,9 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
|
||||
/**
|
||||
* @param int $count
|
||||
* @return $this
|
||||
* @return Item
|
||||
*/
|
||||
public function setCount(int $count){
|
||||
public function setCount(int $count) : Item{
|
||||
$this->count = $count;
|
||||
|
||||
return $this;
|
||||
@ -677,9 +677,9 @@ class Item implements ItemIds, \JsonSerializable{
|
||||
|
||||
/**
|
||||
* @param int $meta
|
||||
* @return $this
|
||||
* @return Item
|
||||
*/
|
||||
public function setDamage(int $meta){
|
||||
public function setDamage(int $meta) : Item{
|
||||
$this->meta = $meta !== -1 ? $meta & 0x7FFF : -1;
|
||||
|
||||
return $this;
|
||||
|
@ -41,7 +41,7 @@ class ItemBlock extends Item{
|
||||
parent::__construct($itemId ?? $this->block->getId(), $meta, $this->block->getName());
|
||||
}
|
||||
|
||||
public function setDamage(int $meta){
|
||||
public function setDamage(int $meta) : Item{
|
||||
$this->block->setDamage($meta !== -1 ? $meta & 0xf : 0);
|
||||
return parent::setDamage($meta);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user