pocketmine\Player::removeWindow PHP Method

removeWindow() public method

public removeWindow ( pocketmine\inventory\Inventory $inventory )
$inventory pocketmine\inventory\Inventory
    public function removeWindow(Inventory $inventory)
    {
        $inventory->close($this);
        if ($this->windows->contains($inventory)) {
            $id = $this->windows[$inventory];
            $this->windows->detach($this->windowIndex[$id]);
            unset($this->windowIndex[$id]);
        }
    }

Usage Example

 public function onOpen(Player $who)
 {
     if ($this->getType()->getNetworkType() === 2) {
         $who->sendMessage("Not Bug Fix!");
         $who->sendMessage("Not Use Furnace!");
         $who->removeWindow($this);
         return;
     }
     parent::onOpen($who);
     $pk = new ContainerOpenPacket();
     $pk->windowid = $who->getWindowId($this);
     $pk->type = $this->getType()->getNetworkType();
     $pk->slots = $this->getSize();
     $holder = $this->getHolder();
     if ($holder instanceof Vector3) {
         $pk->x = $holder->getX();
         $pk->y = $holder->getY();
         $pk->z = $holder->getZ();
     } else {
         $pk->x = $pk->y = $pk->z = 0;
     }
     $who->dataPacket($pk);
     $this->sendContents($who);
 }
Player