I'm trying to make a function that blocks players from executing certain commands while they're spectating another player, but it doesn't seem to work. Any ideas? PHP: public function onCmd(PlayerCommandPreprocessEvent $event) { $player = $event->getPlayer(); $str = str_split($event->getMessage()); $command = explode(' ', $event->getMessage())[0]; $commandCheck = false; $allowed = ['/freeze', '/msg', '/ban', '/unban', '/kick']; if(strpos($event->getMessage(), '/spectate') !== false) $commandCheck = true; if (!isset($this->plugin->spectators[$player->getName()])) return; if ($str[0] != '/') { return; } if (!$commandCheck) { if (!$player->isOp()) { if (in_array(strtolower($command), $allowed)) return; $player->sendMessage(TextFormat::RED . 'You cannot use this command while spectating.'); return $event->setCancelled(true); } } else return;}[PHP]