Why m'y code doesnt plz can you fix that Thx . PHP: public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool { if($sender instanceof Player) { if(strtolower($command->getName()) == 'atp') { if(count($args) == 1 || count($args) == 2) { $action = strtolower($args[0]); if($action == 'kill' || $action == 'death' || $action == 'break' || $action == 'place') { $data = [ 'type' => $action, 'x' => round($sender->getX()), 'y' => round($sender->getY()), 'z' => round($sender->getZ()), 'level' => strtolower($sender->getLevel()->getName()) ]; $this->save($data); $this->create($action); return true; } $user = $this->users->query("SELECT * FROM `users` WHERE `nickname` = '$action'")->fetchArray(SQLITE3_ASSOC); if($user !== false) $sender->sendMessage(str_replace('{player}', $action, $this->config['titleStat'])."\n§aMatar: §d".$user['kill']."\n§aMuerto: §d".$user['death']."\n§aRoto: §d".$user['break']."\n§aLiberar: §d".$user['place']); else $sender->sendMessage($this->config['userNotExist']); } else $sender->sendMessage('§eUse: /atp <kill/death/break/place> [player]'); } } } PHP: [10:20:10] [Server thread/CRITICAL]: Unhandled exception executing command 'atp' in atp: Return value of AlexBrin\aTopPlayers::onCommand() must be of the type boolean, none returned [10:20:10] [Server thread/CRITICAL]: TypeError: "Return value of AlexBrin\aTopPlayers::onCommand() must be of the type boolean, none returned" (EXCEPTION) in "aTopPlayers_v1/src/AlexBrin/aTopPlayers" at line 66
Sorry i send thé wrong code PHP: public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool { if($sender instanceof Player) { if(strtolower($command->getName()) == 'atp') { if(count($args) == 1 || count($args) == 2) { $action = strtolower($args[0]); if($action == 'kill' || $action == 'death' || $action == 'break' || $action == 'place') { $data = [ 'type' => $action, 'x' => round($sender->getX()), 'y' => round($sender->getY()), 'z' => round($sender->getZ()), 'level' => strtolower($sender->getLevel()->getName()) ]; $this->save($data); $this->create($action); return true; } $user = $this->users->query("SELECT * FROM `users` WHERE `nickname` = '$action'")->fetchArray(SQLITE3_ASSOC); if($user !== false) $sender->sendMessage(str_replace('{player}', $action, $this->config['titleStat'])."\n§aMatar: §d".$user['kill']."\n§aMuerto: §d".$user['death']."\n§aRoto: §d".$user['break']."\n§aLiberar: §d".$user['place']); else $sender->sendMessage($this->config['userNotExist']); } else $sender->sendMessage('§eUse: /atp <kill/death/break/place> [player]'); } } }
No, you need to return a boolean: either true to suppress the default usage message for the command, or false to display it.
Sorry i m noob can you fix syntaxe error Unexepted else: PHP: public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool { if($sender instanceof Player) { if(strtolower($command->getName()) == 'atp') { if(count($args) == 1 || count($args) == 2) { $action = strtolower($args[0]); return true; if($action == 'kill' || $action == 'death' || $action == 'break' || $action == 'place') { $data = [ 'type' => $action, 'x' => round($sender->getX()), 'y' => round($sender->getY()), 'z' => round($sender->getZ()), 'level' => strtolower($sender->getLevel()->getName()) ]; $this->save($data); $this->create($action); return true; $user = $this->users->query("SELECT * FROM `users` WHERE `nickname` = '$action'")->fetchArray(SQLITE3_ASSOC); if($user !== false) $sender->sendMessage(str_replace('{player}', $action, $this->config['titleStat'])."\n§aMatar: §d".$user['kill']."\n§aMuerto: §d".$user['death']."\n§aRoto: §d".$user['break']."\n§aLiberar: §d".$user['place']); return true; } else { $sender->sendMessage($this->config['userNotExist']); return true; } else { $sender->sendMessage('§eUse: /atp <kill/death/break/place> [player]'); return true; } } } } } } }
Perhaps you should try to tell people what you think you are doing when you don't know why you wrote the wrong code?