mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 14:35:35 +00:00
don't try to send contents during inventory construction
This commit is contained in:
parent
85b2b2ae2e
commit
4a1fc1bdf7
@ -59,7 +59,7 @@ abstract class BaseInventory implements Inventory{
|
||||
$this->slots = new \SplFixedArray($size ?? $this->getDefaultSize());
|
||||
$this->title = $title ?? $this->getName();
|
||||
|
||||
$this->setContents($items);
|
||||
$this->setContents($items, false);
|
||||
}
|
||||
|
||||
abstract public function getName() : string;
|
||||
@ -105,8 +105,9 @@ abstract class BaseInventory implements Inventory{
|
||||
|
||||
/**
|
||||
* @param Item[] $items
|
||||
* @param bool $send
|
||||
*/
|
||||
public function setContents(array $items){
|
||||
public function setContents(array $items, bool $send = true){
|
||||
if(count($items) > $this->getSize()){
|
||||
$items = array_slice($items, 0, $this->getSize(), true);
|
||||
}
|
||||
@ -123,7 +124,9 @@ abstract class BaseInventory implements Inventory{
|
||||
}
|
||||
}
|
||||
|
||||
$this->sendContents($this->getViewers());
|
||||
if($send){
|
||||
$this->sendContents($this->getViewers());
|
||||
}
|
||||
}
|
||||
|
||||
protected function doSetItemEvents(int $index, Item $newItem) : ?Item{
|
||||
|
@ -84,8 +84,9 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{
|
||||
|
||||
/**
|
||||
* @param Item[] $items
|
||||
* @param bool $send
|
||||
*/
|
||||
public function setContents(array $items){
|
||||
public function setContents(array $items, bool $send = true){
|
||||
$size = $this->getSize();
|
||||
if(count($items) > $size){
|
||||
$items = array_slice($items, 0, $size, true);
|
||||
@ -103,7 +104,9 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{
|
||||
}
|
||||
}
|
||||
|
||||
$this->sendContents($this->getViewers());
|
||||
if($send){
|
||||
$this->sendContents($this->getViewers());
|
||||
}
|
||||
}
|
||||
|
||||
public function onOpen(Player $who){
|
||||
|
@ -114,8 +114,9 @@ interface Inventory{
|
||||
|
||||
/**
|
||||
* @param Item[] $items
|
||||
* @param bool $send
|
||||
*/
|
||||
public function setContents(array $items);
|
||||
public function setContents(array $items, bool $send = true);
|
||||
|
||||
/**
|
||||
* @param Player|Player[] $target
|
||||
|
Loading…
x
Reference in New Issue
Block a user