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

I don’t understand this error

Discussion in 'Plugin Help' started by WEATHERCRAFTYT1, Jul 21, 2020.

  1. WEATHERCRAFTYT1

    WEATHERCRAFTYT1 Baby Zombie

    Messages:
    121
    I’m trying to get this plugin to work but I get this error


    [23:03:24] [Server thread/INFO]: Enabling yBedWars v0.1
    Fatal error: Declaration of ru\yarka\bedwars\entity\Shopkeeper::saveNBT() must be compatible with pocketmine\entity\Villager::saveNBT(): void in /home/container/plugins/BedWars1.0-master/src/ru/yarka/bedwars/entity/Shopkeeper.php on line 186
    [23:03:24] [Server thread/EMERGENCY]: An unrecoverable error has occurred and the server has crashed. Creating a crash dump


    PHP:
    public function openShop(Player $player) {
        
    $i 0;
        
    $shop = new VirtualInventory($player);
        
    $shop->setTitle("Score");
        foreach (
    $this->items as $icon => $content) {
          
    $iconItem Item::get($icon0$i 1);
          
    $iconItem->setCustomName(constant(self::class . '::CATEGORY_' . ($i 1)));
          
    $shop->setItem($i$iconItem);
          
    $shop->bindItem($i++, function () use ($player$shop$i$icon) {
            
    $categoryShop = new VirtualInventory($player);
            
    $categoryShop->setTitle(constant(self::class . '::CATEGORY_' $i));
            foreach (
    $this->items[$icon] as $i => $item) {
              
    /** @var Item $itemItem */
              
    $itemItem = clone $item[0];
              
    $price Item::get(constant(Area::class . '::DROP_ID_' strtoupper($item[1][1])), 0$item[1][0]);
              
    $itemItem->setCustomName(($this->getResourceCount($player$price) >= $price->getCount() ? TextFormat::GREEN TextFormat::RED) . 'Стоимость ' $price->getCount() . ' ' . (
                
    $price->getId() === Area::DROP_ID_BRONZE 'Bronze' : (
                
    $price->getId() === Area::DROP_ID_IRON 'Iron' 'Gold'
                
    )));
              
    $categoryShop->setItem($i$itemItem);
              
    $categoryShop->bindItem($i, function (Item $pricePlayer $playerItem $itemint $iItem $itemItem) {
                
    $itemItem->setCustomName(($this->getResourceCount($player$price) >= $price->getCount() ? TextFormat::GREEN TextFormat::RED) . 'Стоимость ' $price->getCount() . ' ' . (
                  
    $price->getId() === Area::DROP_ID_BRONZE 'Bronze' : (
                  
    $price->getId() === Area::DROP_ID_IRON 'Iron' 'Gold'
                  
    )));
                if (
    $this->getResourceCount($player$price) < $price->getCount()) {
                  return;
                }
                if (!isset(
    $this->state[strtolower($player->getName())]) || $this->state[strtolower($player->getName())] !== 'BUY_' $i) {
                  
    $this->state[strtolower($player->getName())] = 'BUY_' $i;
                  return;
                }
                unset(
    $this->state[strtolower($player->getName())]);
                
    $player->getInventory()->removeItem($price);
                
    $player->getInventory()->addItem($item);
              }, 
    $price$player$item[0], $i$itemItem);
            }
            
    $player->addWindow($categoryShop);
          });
        }
        
    $player->addWindow($shop);
      }

      public function 
    saveNBT() {

      }


      public function 
    getResourceCount(Player $playerItem $resource): int {
        
    $count 0;
        foreach (
    $player->getInventory()->getContents() as $item) {
          if (
    $item->getId() === $resource->getId()) {
            
    $count += $item->getCount();
          }
        }
        return 
    $count;
      }
    }
    anyone knows how to fix this
     
  2. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    give line 186 please
     
  3. tokoyami ds

    tokoyami ds Spider Jockey

    Messages:
    25
    Specify which line is line 186 in this file!

    Otherwise this post will not have an answer
     
  4. Primus

    Primus Zombie Pigman

    Messages:
    749
    PHP:
    # Add scalar type hint here
    public function saveNBT() : void {

    }
     
  5. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    401
    GitHub:
    godweedzao
    why it dosnt have anwser?:confused:
    he should just give us line 186 to check better what is problem
     
  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.