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

I have an Error with FormAPI

Discussion in 'Development' started by DerCooleVonDem, Jan 17, 2021.

  1. DerCooleVonDem

    DerCooleVonDem Spider Jockey

    Messages:
    37
    GitHub:
    Soon
    My Code:

    PHP:
    public function computer($player){
            
    $cfg $this->getConfig();

            
    $api $this->getServer()->getPluginManager()->getPlugin("FormAPI");
            if(
    $api === null || $api->isDisabled()){
                return;
            }
            
    $form $api->createSimpleForm(function (Player $player, array $data){
                
    $result $data[0];
                if(
    $result === null){
                    return;
                }
                switch(
    $data){
                    case 
    0:
                        
    $player->sendMessage($this->getConfig()->get("computer-verlassen-msg"));

                        return;
                    case 
    1:
                        
    $this->quests($player);

                        return;
                }
            });
            
    $form->setTitle($cfg->get("computer-title"));
            
    $form->setContent($cfg->get("computer-content"));
            
    $form->addButton($cfg->get("computer-verlassen"));
            
    $form->addButton($cfg->get("computer-quests"));
            
    $form->sendToPlayer($player);

        }
    The Error:
    Code:
    [13:16:18] [Server thread/CRITICAL]: TypeError: "Argument 2 passed to derc\qcp\main::derc\qcp\{closure}() must be of the type array, int given, called in phar:///home/minecraft/plugins/FormAPI.phar/src/jojoe77777/FormAPI/Form.php on line 46" (EXCEPTION) in "plugins/QCP (3).phar/src/derc/qcp/main" at line 104
    What i should do?
     
  2. Primus

    Primus Zombie Pigman

    Messages:
    749
    PHP:
    $form $api->createSimpleForm(function (Player $player, array $data){
    to
    PHP:
    $form $api->createSimpleForm(function (Player $playerint $data){
     
  3. DerCooleVonDem

    DerCooleVonDem Spider Jockey

    Messages:
    37
    GitHub:
    Soon
  4. DerCooleVonDem

    DerCooleVonDem Spider Jockey

    Messages:
    37
    GitHub:
    Soon
  5. Primus

    Primus Zombie Pigman

    Messages:
    749
    Should I guess the error, or you will let me know?
     
  6. DerCooleVonDem

    DerCooleVonDem Spider Jockey

    Messages:
    37
    GitHub:
    Soon
    Code:
    [16:23:45] [Server thread/CRITICAL]: TypeError: "Argument 2 passed to derc\qcp\main::derc\qcp\{closure}() must be of the type array, int given, called in phar:///home/minecraft/plugins/FormAPI.phar/src/jojoe77777/FormAPI/Form.php on line 46" (EXCEPTION) in "plugins/QCP (9).phar/src/derc/qcp/main" at line 93
    
    [16:23:45] [Server thread/CRITICAL]: #0 plugins/FormAPI.phar/src/jojoe77777/FormAPI/Form(46): derc\qcp\main->derc\qcp\{closure}(object pocketmine\Player, integer 1)
     
  7. DerCooleVonDem

    DerCooleVonDem Spider Jockey

    Messages:
    37
    GitHub:
    Soon
    Its almost the same error
     
  8. Primus

    Primus Zombie Pigman

    Messages:
    749
    You have not changed the code like I told you to. The plugin is running from .phar file, so I doubt that you made the changes, compiled and ran the file. Can you tell me how did you edit the code? Make sure it is executing the code you have edited!
     
  9. DerCooleVonDem

    DerCooleVonDem Spider Jockey

    Messages:
    37
    GitHub:
    Soon
    PHP:
     $form $api->createSimpleForm(function (Player $player, array $data){
    to:

    PHP:
     $form $api->createSimpleForm(function (Player $playerint $data){
     
  10. Primus

    Primus Zombie Pigman

    Messages:
    749
    Then it is not the code being executed!
     
  11. DerCooleVonDem

    DerCooleVonDem Spider Jockey

    Messages:
    37
    GitHub:
    Soon
    The Error says that this code causes Problems
     
  12. Primus

    Primus Zombie Pigman

    Messages:
    749
    The error message says that the code that causes the problem is inside a frickin Phar file. Did you edit the .phar file directly?
    Code:
    "plugins/QCP (9).phar/src/derc/qcp/main" at line 93
    
     
  13. DerCooleVonDem

    DerCooleVonDem Spider Jockey

    Messages:
    37
    GitHub:
    Soon
    Usually plugins are created as a folder structure and then converted into a ZIP file.
    Then the ZIP file is converted into a PHAR file. That's why it says .PHAR.
     
  14. Primus

    Primus Zombie Pigman

    Messages:
    749
    Did you seriously think that every developer when creating plugins, on every single change of the code has to go through all that process?

    Did you know that you can use plugin DevTools which will load plugins in folder structure. I bet you did, however did you know that you don't have to .zip the file! You can use /makeplugin <pluginName> command which will take folder structured plugin and turn it into .phar file!

    I'm still baffled.

    Did you really unphar it, change the code, zip the folder and then phar the archive?
     
  15. DerCooleVonDem

    DerCooleVonDem Spider Jockey

    Messages:
    37
    GitHub:
    Soon
    Do you think I'm somehow mentally behind?
    I know how to make plugins and work on a large server.
    I'm the error-obscure because I have no idea why my script that hasn't let me in the sting for months suddenly doesn't go anymore
    I ask for help here and get an answer but if you don't know what error messages look like and that's normal when you upload a PHAR to the server.

    You can help but if you really have no idea about it then don't confuse me any further
    Thank you anyway
     
  16. DerCooleVonDem

    DerCooleVonDem Spider Jockey

    Messages:
    37
    GitHub:
    Soon
    Of course I can also recycle older plugins but I wanted to educate myself here with you nice people.
    But I'm sorry if you misunderstand my questions and then think I'm an idiot.
    I come from Germany and I learned English at school and apparently can't do it enough.

    In any case, I know how to convert plugins.
    Otherwise the plugin would not be loaded at all and it would not be able to play any errors at all.
     
  17. DerCooleVonDem

    DerCooleVonDem Spider Jockey

    Messages:
    37
    GitHub:
    Soon
    In addition, we have specifications and do not test our plugins locally
    So that other team members can also look at the process, we upload the plugins step by step to a server as a phar file.

    I didn't edit anything but programmed everything myself
     
  18. Primus

    Primus Zombie Pigman

    Messages:
    749
    Fair enough. Upload the plugin here, I'll check the code for you and fix it.
     
  19. DerCooleVonDem

    DerCooleVonDem Spider Jockey

    Messages:
    37
    GitHub:
    Soon
  20. RicardoMilos384

    RicardoMilos384 Slime

    Messages:
    82
    GitHub:
    ricardomilos384
    PHP:
    $form $api->createSimpleForm(function (Player $player$data null){
     
    ItsInspire 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.