When I click the inventory appears and then disappears how to fix it please ? File 1 PHP: public function onTouchh(PlayerInteractEvent $event) { $Player = $event->getPlayer(); $Level = $Player->getLevel(); $Type = ($Level->getFolderName() == $this->plugin->lobby_name) ? 1 : 0; $X = round($Player->getX() - 0.5); $Z = round($Player->getZ() - 0.5); if ($Level->getBlockIdAt($X,0,$Z) != 54) { $Level->setBlock(new Vector3($X,0,$Z),Block::get(54),true,true); $nbt = new CompoundTag("", [ new ListTag("Items", []), new StringTag("id", Tile::CHEST), $this->plugin ]); $nbt->Items->setTagType(NBT::TAG_Compound); $tile = Tile::createTile("Chest", $Level->getChunk($X >> 4,$Z >> 4), $nbt); //$chest = new Chest($Level->getChunk($X >> 4,$Z >> 4,true),new CompoundTag(false,array( new IntTag("x",$X), new IntTag("y",0), new IntTag("z",$Z), new StringTag("id",Tile::CHEST))),$this->plugin); $Level->addTile($tile); } else $chest = $Level->getTile(new Vector3($X,0,$Z)); if ($Level->getBlockIdAt($X,1,$Z) != 54) $Level->setBlock(new Vector3($X,1,$Z),Block::get(0),true,true); $chest = new BuyingInventory($Level->getTile(new Vector3($X,0,$Z)),$Player); $contents = []; switch ($Type) { case 0: foreach ($this->plugin->Buys_Values as $Buy_Value) $contents []= Item::get($Buy_Value[0],0,1); break; case 1: if ($this->plugin->Status == 0) { foreach ($this->plugin->MapsList as $Map) $contents []= Item::get(35,$Map[0],($Map[4] == 0) ? 99 : $Map[4]); } else { $contents []= Item::get(345,0,1); foreach ($this->plugin->game->Teams as $Name => $Team) $contents []= Item::get(35,$this->plugin->getTeamDataByName($Name),(count($Team->Players) == 0) ? 99 : count($Team->Players)); } break; } $chest->setContents($contents); $this->plugin->setState("buying_chest",$Player,$chest); $this->plugin->setState("buying_type",$Player,$Type); $this->plugin->setState("buying_menu",$Player,-1); $Player->addWindow($chest); $event->setCancelled(true); $Level = $Player->getLevel(); if ((!$this->plugin->game) || ($this->plugin->game->level_name != $Level->getFolderName())) return; $X = $Player->getFloorX(); $Y = $Player->getFloorY() - 1; $Z = $Player->getFloorZ(); $Block = $Level->getBlock(new Vector3($X,$Y,$Z)); if ($Block->getId() == 133) { $event->setCancelled(true); } } File 2 PHP: class BuyingInventory extends CustomInventory{ protected $client; protected $holder; public function __construct($holder,$client){ $this->client = $client; parent::__construct($holder,InventoryType::get(InventoryType::CHEST),[],null,""); }
The inventory holder is 'null' due to not being done correctly, you forgot the x,y,z in the compound tag: PHP: new IntTag("x", $player->getX()),new IntTag("y", $player->getY()),new IntTag("z", $player->getZ()) Also you forgot the types in the BuyingInventory Class: PHP: public function __construct(Chest $holder, Player $client){ I'm assuming those were the types you were using, feel free to correct them.
ofcourse you can edit it to whatever you have defined he just want to make it simpler for other to understand
Then type the error out. If you know it is hard to read it from your console, it is even harder to read it from an image on a forum.