1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Help windows

Discussion in 'Plugin Help' started by Mochi, May 17, 2020.

  1. Mochi

    Mochi Baby Zombie

    Messages:
    113
    Fatal error: Class skywars\Windows\Windows contains 3 abstract methods and must therefore be declared abstract or implement the remaining methods (pocketmine\inventory\ContainerInventory::getNetworkType, pocketmine\inventory\BaseInventory::getName, pocketmine\inventory\BaseInventory::getDefaultSize) in /storage/emulated/0/PocketMine-MP/plugins/SW09/src/skywars/Windows/Windows.php on line 19

    Code:
    PHP:
    <?php

    namespace skywars\Windows;

    use 
    pocketmine\block\Block;
    use 
    pocketmine\inventory\CustomInventory;
    use 
    pocketmine\Player;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\inventory\InventoryType;
    use 
    pocketmine\network\protocol\UpdateBlockPacket;
    use 
    pocketmine\nbt\tag\CompoundTag;
    use 
    pocketmine\nbt\tag\StringTag;
    use 
    pocketmine\tile\Tile;
    use 
    pocketmine\nbt\tag\IntTag;
    use 
    pocketmine\nbt\NBT;
    use 
    pocketmine\network\protocol\BlockEntityDataPacket;
    use 
    pocketmine\inventory\InventoryHolder;

    class 
    Windows extends CustomInventory{
        
        protected 
    $customName "";
        protected 
    $tile;
        protected 
    $block;
        private 
    $double false;
        private 
    $local "menu";
        private 
    $pag 1;
        
        public function 
    __construct(Player $player$size 27$name "") {
            
    $this->tile Tile::CHEST;
            
    $this->block 54;
            
    $type InventoryType::get(InventoryType::CHEST);
            if(
    $size >= 54){
                
    $this->double true;
            }
            
    $this->customName $name;
            
    $holder = new WindowHolder($player->getFloorX(), $player->getFloorY() + 2$player->getFloorZ(), $this);
            
    parent::__construct($holder$type, [], $size);
        }
        
        public function 
    setLocal($local){
            
    $this->local $local;
        }
        
        public function 
    getLocal(){
            return 
    $this->local;
        }
        
        public function 
    setPag(int $pag){
            
    $this->pag $pag;
        }
        
        public function 
    getPag(){
            return 
    $this->pag;
        }
        
        public function 
    onOpen(Player $who) : void{
            
    $this->holder $holder = new WindowHolder($who->getFloorX(), $who->getFloorY() + 2$who->getFloorZ(), $this);
            
    $pk = new UpdateBlockPacket();
            
    $pk->$holder->x;
            
    $pk->$holder->y;
            
    $pk->$holder->z;
            
    $pk->blockId $this->block;
            
    $pk->blockData 0;
            
    $pk->flags UpdateBlockPacket::FLAG_ALL;
            
    $who->dataPacket($pk);
            
    $c = new CompoundTag("", [
            new 
    StringTag("id"$this->tile),
            new 
    IntTag("x", (int) $holder->x),
            new 
    IntTag("y", (int) $holder->y),
            new 
    IntTag("z", (int) $holder->z),
            new 
    IntTag("pairx", (int) $holder->1),
            new 
    IntTag("pairz", (int) $holder->z),
            new 
    StringTag("CustomName"$this->customName)
            ]);
            
    $nbt = new NBT(NBT::LITTLE_ENDIAN);
            
    $nbt->setData($c);
            
    $pk = new BlockEntityDataPacket();
            
    $pk->$holder->x;
            
    $pk->$holder->y;
            
    $pk->$holder->z;
            
    $pk->namedtag $nbt->write();
            
    $who->dataPacket($pk);
            if(
    $this->double){
                
    $pk = new UpdateBlockPacket();
                
    $pk->$holder->1;
                
    $pk->$holder->y;
                
    $pk->$holder->z;
                
    $pk->blockId $this->block;
                
    $pk->blockData 0;
                
    $pk->flags UpdateBlockPacket::FLAG_ALL;
                
    $who->dataPacket($pk);
                
    $c = new CompoundTag("", [
                new 
    StringTag("id"$this->tile),
                new 
    IntTag("x", (int) $holder->1),
                new 
    IntTag("y", (int) $holder->y),
                new 
    IntTag("z", (int) $holder->z),
                new 
    StringTag("CustomName"$this->customName)
                ]);
                
    $nbt = new NBT(NBT::LITTLE_ENDIAN);
                
    $nbt->setData($c);
                
    $pk = new BlockEntityDataPacket();
                
    $pk->$holder->1;
                
    $pk->$holder->y;
                
    $pk->$holder->z;
                
    $pk->namedtag $nbt->write();
                
    $who->dataPacket($pk);
            }
            
    usleep(500000);
            
    parent::onOpen($who);
            
    $this->sendContents($who);
        }
        
        public function 
    onClose(Player $who) : void{
            
    $holder $this->holder;
            
    $pk = new UpdateBlockPacket();
            
    $pk->$holder->x;
            
    $pk->$holder->y;
            
    $pk->$holder->z;
            
    $pk->blockId $who->getLevel()->getBlockIdAt($holder->x$holder->y$holder->z);
            
    $pk->blockData $who->getLevel()->getBlockDataAt($holder->x$holder->y$holder->z);
            
    $pk->flags UpdateBlockPacket::FLAG_ALL;
            
    $who->dataPacket($pk);
            if(
    $this->double){
                
    $pk = new UpdateBlockPacket();
                
    $pk->$holder->1;
                
    $pk->$holder->y;
                
    $pk->$holder->z;
                
    $pk->blockId $who->getLevel()->getBlockIdAt($holder->1$holder->y$holder->z);
                
    $pk->blockData $who->getLevel()->getBlockDataAt($holder->1$holder->y$holder->z);
                
    $pk->flags UpdateBlockPacket::FLAG_ALL;
                
    $who->dataPacket($pk);
            }
            
    usleep(550000);
            
    parent::onClose($who);
        }
    }
     
  2. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    Let's see if we can reword the error for you to understand...

    Fatal error: Class Windows missing 3 functions which must be implemented. getNetworkType() getName() getDefaultSize() in /storage/emulated/0/PocketMine-MP/plugins/SW09/src/skywars/Windows/Windows.php
     
    ethaniccc and HimbeersaftLP like this.
  3. Mochi

    Mochi Baby Zombie

    Messages:
    113
    Can you give me example please?
     
  4. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Just implement these methods like you did with the other ones.
     
  5. Mochi

    Mochi Baby Zombie

    Messages:
    113
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.