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

Receiving Fatal Error Declaration of myplugin\Loader::onCommand

Discussion in 'Development' started by TheThreeGuns, Aug 14, 2017.

  1. TheThreeGuns

    TheThreeGuns Creeper

    Messages:
    3
    Code:
    Fatal error: Declaration of myplugin\Loader::onCommand(pocketmine\command\CommandSender $sender, pocketmine\command\Command $command, $label, array $args) must be compatible with pocketmine\command\CommandExecutor::onCommand(pocketmine\command\CommandSender $sender, pocketmine\command\Command $command, string $label, array $args): bool in phar:///plugins/MyPlugin_1.0.0.phar/src/myplugin/Main.php on line 14{\
    My code: https://pastebin.com/21qYhd5v

    thank u for helping me

    (I am new to this plugin coding stuff)
     
    Last edited: Aug 14, 2017
  2. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    A. Don't put your entire post in a code braces.
    B. Show us your code. don't link it.
    C. Poct in the correct section! This should be in Development.
    Read the error carefully. It tells you exactly what you did wrong. Compare the parameters within the function you have and what you need.
     
    Muqsit likes this.
  3. dktapps

    dktapps Administrator Staff Member PMMP Team

    Messages:
    774
    GitHub:
    dktapps
    You need to change the signature of your onCommand() function:

    Code:
    public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool{
    
    This is due to changes made to the API recently adding scalar parameter and return type declarations.
     
    jasonwynn10 likes this.
  4. TheThreeGuns

    TheThreeGuns Creeper

    Messages:
    3
    hello, now when i try to do /beta nothing happens i tried adding the permission too.
     
  5. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    Make a github account, make a new repository, then install a git client to push your entire plugin to the repo. Without the entire plugin we can't really help you.
     
    jasonwynn10 likes this.
  6. TheThreeGuns

    TheThreeGuns Creeper

    Messages:
    3
    plugin Main.php & plugin.yml are on my github now: https://github.com/thethreeguns/myplugin1gkits/tree/master
     
  7. RoyalMCPE

    RoyalMCPE Slime

    Messages:
    87
  8. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
  9. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    That's better - now compare your folder structure with DevTools, for example. You'll see that you don't have a src folder with a subfolder that corresponds to your namespace, which in turn contains (optional subfolders or) your Main class... for which the path must be correctly specified in plugin.yml under 'main'.
     
  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.