pocketmine\inventory\Inventory::getContents PHP Метод

getContents() публичный Метод

public getContents ( ) : Item[]
Результат pocketmine\item\Item[]
    public function getContents();

Usage Example

Пример #1
0
 public function saveInventory(Player $player, Inventory $inv)
 {
     $n = trim(strtolower($player->getName()));
     if ($n === "") {
         return false;
     }
     $d = substr($n, 0, 1);
     if (!is_dir($this->getDataFolder() . $d)) {
         mkdir($this->getDataFolder() . $d);
     }
     $path = $this->getDataFolder() . $d . "/" . $n . ".yml";
     $cfg = new Config($path, Config::YAML);
     $yaml = $cfg->getAll();
     if ($this->isGlobal) {
         $ln = "*";
     } else {
         $ln = trim(strtolower($player->getLevel()->getName()));
     }
     $yaml[$ln] = [];
     foreach ($inv->getContents() as $slot => &$item) {
         $yaml[$ln][$slot] = implode(":", [$item->getId(), $item->getDamage(), $item->getCount()]);
     }
     $inv->clearAll();
     $cfg->setAll($yaml);
     $cfg->save();
     return true;
 }
All Usage Examples Of pocketmine\inventory\Inventory::getContents