Try this: PHP: public function onChat(PlayerCommandPreprocessEvent $event) { $player = $event->getPlayer(); $command = explode(" ", strtolower($event->getMessage())); if ($command[0] === "/stop") { if(!($player instanceof Player)){ $event->setCancelled(true); } } }
.. Do you even understand what I wrote? PHP: public function onChat(PlayerCommandPreprocessEvent $event) { $player = $event->getPlayer(); $command = explode(" ", strtolower($event->getMessage())); if ($command[0] === "/stop") { // Checks the command if(!($player instanceof Player)){ // Checks whether the Sender IS NOT a Player $event->setCancelled(true); } } }
Do you even understand what you wrote? He asked to disable stop directly, even to disable for console. Your function only disabled for players. PlayerCommandPreprocessEvent isn't fired for non-player commands. Otherwise what do you expect getPlayer to return for non-player? Read the docs. What if hosting used another way than /stop to stop the server? And what if you seriously want to stop the server?
yes they stop my server when they see it but hosting doesn´t stop my server when stop command wont work i think
I have one really cool suggestion: 1) Extract PocketMine-MP.phar to folder 2) Delete all files/ contents of files where is "stop" command 3) Use pmt.mcpe.me(thanks PEMapModder) to create new phar