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

Please help me to fix an error

Discussion in 'Plugin Help' started by Ayush, Mar 15, 2021.

  1. Ayush

    Ayush Witch

    Messages:
    62
    • Hi, I m making a plugin and a error occurred the error is
    • PHP:
      syntax errorunexpected ';' at line 299 
    And this is code
    PHP:
                        switch ($action->getSlot()) {
                            case 
    50:
                                foreach (
    array_reverse($this->minionInformation->getInventory()->getContents(), true) as $slot => $item) {
                            if(!
    $this->getPlayer()->getInventory()->contains(Item::get(Item::DIAMOND0136)){
                  
    /**Line229 **/              $this->getPlayer()->sendMessage("§1You don't have enough diamonds to upgrade..");
                            }
                            
                            
    $this->minionInformation->setLevel() - 2;
                            
    $this->getPlayer()->sendMessage("§1Upgraded the minion!");
                            
    $this->getPlayer()->getInventory()->removeItem(Item::get(Item::DIAMOND0136);
                                
    $player->removeWindow($action->getInventory());
                                }
    Please try to help me fast cuz I need this plugin so much
    And I'm using invmenu
     
  2. Ayush

    Ayush Witch

    Messages:
    62
    :shoghi: please try fast
     
  3. TheBarii

    TheBarii Creeper

    Messages:
    5
    GitHub:
    BariPlayzYT
    Simply don't put a ";" and try it out
     
  4. Primus

    Primus Zombie Pigman

    Messages:
    749
    You're missing matching bracket on line 228. Check the if statement!
     
    minijaham and Ayush like this.
  5. Ayush

    Ayush Witch

    Messages:
    62
    I fixed it but another error occur. Error is here ⏬
    PHP:
    2021-03-16 [01:59:14] [Server thread/CRITICAL]: ParseError"syntax error, unexpected 'return' (T_RETURN)" (EXCEPTIONin "plugins/Aot's plugin (3).phar/src/DaPigGuy/PiggyMinions/entities/MinionEntity" at line 232
    THE code is here
    PHP:
                                   if (!$player->getInventory()->contains(Item::get(Item::DIAMOND0136))){
                                       
    $sender->sendMessage("§l§4You don't have required Items! ")
                                       return;
                                   }
     
  6. Ayush

    Ayush Witch

    Messages:
    62
    Pls try fast
     
  7. WEATHERCRAFTYT1

    WEATHERCRAFTYT1 Baby Zombie

    Messages:
    121
    Your missing a ; before the return
    Try this
    PHP:
     $sender->sendMessage("§l§4You don't have required Items! ");
     
    Ayush likes this.
  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.