public function sendContents($target) { if ($target instanceof Player) { $target = [$target]; } $pk = new ContainerSetContentPacket(); $pk->slots = []; for ($i = 0; $i < $this->getSize(); ++$i) { $pk->slots[$i] = $this->getItem($i); } foreach ($target as $player) { if (($id = $player->getWindowId($this)) === -1 or $player->spawned !== true) { $this->close($player); continue; } $pk->windowid = $id; $player->dataPacket($pk); } }