When I type /fly, it send LytraSystem::NOCONSOLE message, but when I type it in console, it send the LytraSystem::NOCONSOLE too How to solve it ? PHP: <?phpnamespace LytraSystem\Commands;use LytraSystem\LytraSystem;use pocketmine\command\PluginCommand;use pocketmine\command\Command;use pocketmine\command\CommandSender;class FlyCmd extends PluginCommand { public function __construct(string $name, LytraSystem $plugin){ parent::__construct($name, $plugin); $this->setDescription("Flying"); $this->setUsage("§cUsage: /fly"); $this->setPermission("lytrasystem.fly.toggle"); $this->plugin = $plugin; } public function execute(CommandSender $sender, string $alias, array $args) : bool{ if(!$this->testPermission($sender)){ return true; } if(!$sender instanceof Player){ $sender->sendMessage(LytraSystem::NOCONSOLE); return true; } else { $sender->sendMessage($sender->getAllowFlight() === false ? LytraSystem::PREFIX . "§eFly mode telah diaktifkan" : LytraSystem::PREFIX . "§cFly mode telah dinonaktifkan"); $sender->setAllowFlight($sender->getAllowFlight() === false ? true : false); $sender->setFlying($sender->isFlying() === false ? true : false); return true; } }}
PHP: <?phpnamespace LytraSystem\Commands;use LytraSystem\LytraSystem;use pocketmine\command\PluginCommand;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\Player;class FlyCmd extends PluginCommand { public function __construct(string $name, LytraSystem $plugin){ parent::__construct($name, $plugin); $this->setDescription("Flying"); $this->plugin = $plugin; } public function execute(CommandSender $sender, string $alias, array $args) : bool{ if(!$sender->hasPermission("lytrasystem.fly.toggle")){ $sender->sendMessage("You do not have permission to use this command!"); return false; } if(!$sender instanceof Player){ # if sender is not a player $sender->sendMessage(LytraSystem::NOCONSOLE); return false; } $sender->sendMessage($sender->getAllowFlight() === false ? LytraSystem::PREFIX . "§eFly mode telah diaktifkan" : LytraSystem::PREFIX . "§cFly mode telah dinonaktifkan"); $sender->setAllowFlight($sender->getAllowFlight() === false ? true : false); $sender->setFlying($sender->isFlying() === false ? true : false); return true; }} Try this and see if it works. You didn't import pocketmine\Player, and had some unnecessary things in your code.