DoubleChestInventory: remove duplicated code

This commit is contained in:
Dylan K. Taylor 2019-05-26 15:01:32 +01:00
parent 685f5d562b
commit 32e03cd92d
2 changed files with 1 additions and 27 deletions

View File

@ -113,9 +113,7 @@ abstract class BaseInventory implements Inventory{
for($i = 0, $size = $this->getSize(); $i < $size; ++$i){
if(!isset($items[$i])){
if($this->slots[$i] !== null){
$this->clear($i, false);
}
$this->clear($i, false);
}else{
$this->setItem($i, $items[$i], false);
}

View File

@ -27,7 +27,6 @@ use pocketmine\block\tile\Chest;
use pocketmine\item\Item;
use pocketmine\Player;
use function array_merge;
use function array_slice;
use function count;
class DoubleChestInventory extends ChestInventory implements InventoryHolder{
@ -75,29 +74,6 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{
return $result;
}
/**
* @param Item[] $items
* @param bool $send
*/
public function setContents(array $items, bool $send = true) : void{
$size = $this->getSize();
if(count($items) > $size){
$items = array_slice($items, 0, $size, true);
}
for($i = 0; $i < $size; ++$i){
if(!isset($items[$i])){
$this->clear($i, false);
}else{
$this->setItem($i, $items[$i], false);
}
}
if($send){
$this->sendContents($this->getViewers());
}
}
protected function onOpen(Player $who) : void{
parent::onOpen($who);