public function dispatch(CommandSender $sender, $commandLine)
{
$args = explode(" ", $commandLine);
if (count($args) === 0) {
return false;
}
$sentCommandLabel = strtolower(array_shift($args));
$target = $this->getCommand($sentCommandLabel);
if ($target === null) {
return false;
}
$target->timings->startTiming();
try {
if ($this->server->advancedCommandSelector) {
$this->dispatchAdvanced($sender, $target, $sentCommandLabel, $args);
} else {
$target->execute($sender, $sentCommandLabel, $args);
}
} catch (\Throwable $e) {
$sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.exception"));
$this->server->getLogger()->critical($this->server->getLanguage()->translateString("pocketmine.command.exception", [$commandLine, (string) $target, $e->getMessage()]));
$logger = $sender->getServer()->getLogger();
if ($logger instanceof MainLogger) {
$logger->logException($e);
}
}
$target->timings->stopTiming();
return true;
}