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

Solved what is wrong?

Discussion in 'Development' started by Karanpatel567, Oct 6, 2017.

  1. Karanpatel567

    Karanpatel567 Baby Zombie

    Messages:
    115
    GitHub:
    Karanpatel567
    Hey i need help with something, So i'm using Pmmp and i get this crashdump which i cant understand.
    PHP:
    PocketMine-MP Crash Dump Fri Oct 6 16:10:34 GMT 2017

    Error
    Declaration of Karanpatel567\main::onCommand(pocketmine\command\CommandSender $senderpocketmine\command\Command $cmd$labels, array $argsmust be compatible with pocketmine\plugin\PluginBase::onCommand(pocketmine\command\CommandSender $senderpocketmine\command\Command $commandstring $label, array $args): bool
    File
    addWindow/src/Karanpatel567/main
    Line
    64
    Type
    E_COMPILE_ERROR

    THIS CRASH WAS CAUSED BY A PLUGIN

    Code
    :
    [
    55]                 }
    [
    56]             }elseif(!$sender->hasPermission("addwindow.command")){
    [
    57]                 $sender->sendMessage(c::RED"You don't have permission to use this command!");
    [
    58]             }
    [
    59]         }
    [
    60]     }
    [
    61]     public function onDisable(){
    [
    62]         $this->getLogger()->Info(c::RED"addWindow by Karan disabled!");
    [
    63]     }
    [
    64] }
    [
    65]
    [
    66]
    [
    67]
    [
    68]
    [
    69]
    [
    70]
    [
    71]
    [
    72]
    [
    73]
    [
    74
    It says to look at line 64 but there's only a bracket there which finished the class main extends pluginbase.
     
  2. QuiverlyRivalry

    QuiverlyRivalry Zombie Pigman

    Messages:
    491
    GitHub:
    quiverlyrivalry
    is the bracked in the wrong place?
     
  3. Karanpatel567

    Karanpatel567 Baby Zombie

    Messages:
    115
    GitHub:
    Karanpatel567
    no
     
  4. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    In the line with the onCommand() function change
    PHP:
     onCommand(pocketmine\command\CommandSender $senderpocketmine\command\Command $cmd$labels, array $args
    to this
    PHP:
     onCommand(pocketmine\command\CommandSender $senderpocketmine\command\Command $commandstring $label, array $args): bool 
    there was an API change in pmmp :D
     
    armagadon159753 likes this.
  5. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    of course you have to change within the function the variable to the new ones
     
    Karanpatel567 likes this.
  6. Karanpatel567

    Karanpatel567 Baby Zombie

    Messages:
    115
    GitHub:
    Karanpatel567
    K it works but when i execute the command it shows this
    PHP:
    [17:19:15] [Server thread/INFO]: An unknown error occurred while attempting to perform this command
    [17:19:15] [Server thread/CRITICAL]: Unhandled exception executing command 'addwindow' in addwindow: Return value of Karanpatel567\main::onCommand() must be of the type booleannone returned
    [17:19:15] [Server thread/CRITICAL]: TypeError"Return value of Karanpatel567\main::onCommand() must be of the type boolean, none returned" (EXCEPTIONin "addWindow/src/Karanpatel567/main" at line 60
     
  7. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    When you have a return in your onCommand function, you must return a boolean (true or false).
     
  8. Karanpatel567

    Karanpatel567 Baby Zombie

    Messages:
    115
    GitHub:
    Karanpatel567
    how?
     
  9. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    change:
    PHP:
    return; 
    to this
    PHP:
    return true;
    //or this:
    return false;
     
     
  10. Karanpatel567

    Karanpatel567 Baby Zombie

    Messages:
    115
    GitHub:
    Karanpatel567
    PHP:
        public function onCommand(CommandSender $senderCommand $cmdstring $labels, array $args) :bool{
            if(
    strtolower($cmd->getName()) == "addwindow"){
                if(
    $sender->hasPermission("addwindow.command")){
                    
    $sender->sendMessage(c::YELLOW"Sending Inventory! Please be patient.");
                    if(
    $sender instanceof Player){
                    
    $this->sendInventory($sender);
                    }
                }elseif(!
    $sender->hasPermission("addwindow.command")){
                    
    $sender->sendMessage(c::RED"You don't have permission to use this command!");
                    return 
    true;
                }
            }
        }
    i did and it still comes up with same error
     
  11. McpeBooster

    McpeBooster Baby Zombie

    Messages:
    190
    GitHub:
    mcpebooster
    You must add a return true, at the end of your function.
    I will fix this and some other thinks :D
    PHP:
    public function onCommand(CommandSender $senderCommand $commandstring $label, array $args) :bool{
            if(
    strtolower($command->getName()) == "addwindow"){
                if(
    $sender->hasPermission("addwindow.command")){
                    
    $sender->sendMessage(c::YELLOW"Sending Inventory! Please be patient.");
                    if(
    $sender instanceof Player){
                    
    $this->sendInventory($sender);
                    }
                }elseif(!
    $sender->hasPermission("addwindow.command")){
                    
    $sender->sendMessage(c::RED"You don't have permission to use this command!");
                    return 
    true;
                }
            }
           return 
    true;
        }
     
  12. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
  13. Karanpatel567

    Karanpatel567 Baby Zombie

    Messages:
    115
    GitHub:
    Karanpatel567
    Thank you very much ;) It now works. Thanks for helping me
     
  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.