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

Solved Error API Method

Discussion in 'Plugin Help' started by Fritures, Aug 23, 2019.

  1. Fritures

    Fritures Spider Jockey

    Messages:
    47
    So hello, i make an API and i have this error :
    Code:
    Error: "Call to undefined method ClassAPI\Main::setup()" (EXCEPTION) in "plugins/Template/src/Template/Main" at line 15
    Here is my code
    Main ClassAPI
    PHP:
    <?php

    declare(strict_types 1);

    namespace 
    ClassAPI;
    use 
    ClassAPI\API\ClassHandler;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\utils\TextFormat as TF;

    class 
    Main extends PluginBase {

      public function 
    onEnable(){
       
    $this->getServer()->getPluginManager()->registerEvents(new ClassHandler($this), $this);
       
    $this->getLogger()->info(TF::GREEN " is enabled !"); 
      }
     
      public function 
    onDisable(){ 
       
    $this->getLogger()->info(TF::RED " is disabled !"); 
      }

    }

    ?>
    Main Template
    PHP:
    <?php

    namespace Template;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\utils\TextFormat as TF;

    class 
    Main extends PluginBase {

      public 
    $api;

      public function 
    onEnable(){
       
    $this->getLogger()->info(TF::GREEN " is enabled !");
       
    $this->api $this->getServer()->getPluginManager()->getPlugin("ClassAPI");
       
    $this->api->setup();
      }
     
      public function 
    onDisable(){ 
       
    $this->getLogger()->info(TF::RED " is disabled !"); 
      }

    }

    ?>
     
  2. Fadhel

    Fadhel Witch

    Messages:
    68
    GitHub:
    dimbis
    the bug is there's no "setup" function on your code.
     
    HimbeersaftLP likes this.
  3. Fritures

    Fritures Spider Jockey

    Messages:
    47
    Yes but i registered ClassHandlder (contains setup function) on Main ClassAPI so i don't understand
     
  4. Fadhel

    Fadhel Witch

    Messages:
    68
    GitHub:
    dimbis
    you need to learn PHP.
     
  5. Fritures

    Fritures Spider Jockey

    Messages:
    47
    I want your help i had learn PHP !
     
  6. Deniel

    Deniel Spider Jockey

    Messages:
    42
    GitHub:
    DenielWorld
    @Fadhel could of at least have given him some references. Anyways, try to learn how to understand and reproduce your errors. Read through every single line, make sure it makes sense (Don't do that if you have a big plugin). Also you shouldn't make your own API plugin as a beginner, try making some draft plugins, explore PMMP's API, learn more about PHP's in-built functionalities.
     
  7. Rim

    Rim Spider Jockey

    Messages:
    28
    GitHub:
    boomyourbang
    How is that helpful?

    Show your ClassHandler file's code please? Also why do you have two PluginBases?
     
  8. Fadhel

    Fadhel Witch

    Messages:
    68
    GitHub:
    dimbis
    it is helpful.
     
  9. Deniel

    Deniel Spider Jockey

    Messages:
    42
    GitHub:
    DenielWorld
    Well he doesn't get smarter from you telling him to learn PHP.
     
  10. Fadhel

    Fadhel Witch

    Messages:
    68
    GitHub:
    dimbis
    it is helpful he must learn PHP instead of wasting his time asking for help, this is common sense. the thread is already solved i don't get why you are mentioning me on this solved thread.
     
  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.