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 2017Error: Declaration of Karanpatel567\main::onCommand(pocketmine\command\CommandSender $sender, pocketmine\command\Command $cmd, $labels, array $args) must be compatible with pocketmine\plugin\PluginBase::onCommand(pocketmine\command\CommandSender $sender, pocketmine\command\Command $command, string $label, array $args): boolFile: addWindow/src/Karanpatel567/mainLine: 64Type: E_COMPILE_ERRORTHIS CRASH WAS CAUSED BY A PLUGINCode:[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.
In the line with the onCommand() function change PHP: onCommand(pocketmine\command\CommandSender $sender, pocketmine\command\Command $cmd, $labels, array $args) to this PHP: onCommand(pocketmine\command\CommandSender $sender, pocketmine\command\Command $command, string $label, array $args): bool there was an API change in pmmp
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 boolean, none returned[17:19:15] [Server thread/CRITICAL]: TypeError: "Return value of Karanpatel567\main::onCommand() must be of the type boolean, none returned" (EXCEPTION) in "addWindow/src/Karanpatel567/main" at line 60
PHP: public function onCommand(CommandSender $sender, Command $cmd, string $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
You must add a return true, at the end of your function. I will fix this and some other thinks PHP: public function onCommand(CommandSender $sender, Command $command, string $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; }
See https://forums.pmmp.io/threads/updating-a-plugin-to-work-with-different-apis-the-manual-way.3647/