mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +00:00
Inventory: Add a $send parameter to clearAll()
This commit is contained in:
parent
897a31e608
commit
69ddaacc28
@ -351,12 +351,14 @@ abstract class BaseInventory implements Inventory{
|
|||||||
return $this->setItem($index, ItemFactory::get(Item::AIR, 0, 0), $send);
|
return $this->setItem($index, ItemFactory::get(Item::AIR, 0, 0), $send);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clearAll() : void{
|
public function clearAll(bool $send = true) : void{
|
||||||
for($i = 0, $size = $this->getSize(); $i < $size; ++$i){
|
for($i = 0, $size = $this->getSize(); $i < $size; ++$i){
|
||||||
$this->clear($i, false);
|
$this->clear($i, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->sendContents($this->getViewers());
|
if($send){
|
||||||
|
$this->sendContents($this->getViewers());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -188,8 +188,10 @@ interface Inventory{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears all the slots
|
* Clears all the slots
|
||||||
|
*
|
||||||
|
* @param bool $send
|
||||||
*/
|
*/
|
||||||
public function clearAll() : void;
|
public function clearAll(bool $send = true) : void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all the Players viewing the inventory
|
* Gets all the Players viewing the inventory
|
||||||
|
@ -282,14 +282,16 @@ class PlayerInventory extends EntityInventory{
|
|||||||
return parent::doSetItemEvents($index, $newItem);
|
return parent::doSetItemEvents($index, $newItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clearAll() : void{
|
public function clearAll(bool $send = true) : void{
|
||||||
parent::clearAll();
|
parent::clearAll($send);
|
||||||
|
|
||||||
for($i = $this->getSize(), $m = $i + 4; $i < $m; ++$i){
|
for($i = $this->getSize(), $m = $i + 4; $i < $m; ++$i){
|
||||||
$this->clear($i, false);
|
$this->clear($i, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->sendArmorContents($this->getViewers());
|
if($send){
|
||||||
|
$this->sendArmorContents($this->getViewers());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user