Skip to content
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
namespace pocketmine\command;

use pocketmine\command\utils\CommandException;
use pocketmine\command\utils\CommandStringHelper;
use pocketmine\lang\KnownTranslationFactory;
use pocketmine\lang\Translatable;
use pocketmine\permission\PermissionManager;
Expand Down Expand Up @@ -80,6 +81,11 @@ public function __construct(string $name, Translatable|string $description = "",
$this->setAliases($aliases);
}

public function executeRaw(CommandSender $sender, string $commandLabel, string $argLine) : void{
$args = CommandStringHelper::parseQuoteAware($argLine);
$this->execute($sender, $commandLabel, $args);
}

/**
* @param string[] $args
* @phpstan-param list<string> $args
Expand Down
12 changes: 6 additions & 6 deletions src/command/SimpleCommandMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
use function array_shift;
use function array_values;
use function count;
use function explode;
use function implode;
use function str_contains;
use function strcasecmp;
Expand Down Expand Up @@ -207,16 +208,15 @@ private function registerAlias(Command $command, bool $isAlias, string $fallback
}

public function dispatch(CommandSender $sender, string $commandLine) : bool{
$args = CommandStringHelper::parseQuoteAware($commandLine);

$sentCommandLabel = array_shift($args);
if($sentCommandLabel !== null && ($target = $this->getCommand($sentCommandLabel)) !== null){
$parts = explode(" ", $commandLine, 2);
$sentCommandLabel = $parts[0];
if(($target = $this->getCommand($sentCommandLabel)) !== null){
$timings = Timings::getCommandDispatchTimings($target->getLabel());
$timings->startTiming();

try{
if($target->testPermission($sender)){
$target->execute($sender, $sentCommandLabel, $args);
$target->executeRaw($sender, $sentCommandLabel, trim($parts[1] ?? ""));
}
}catch(InvalidCommandSyntaxException $e){
$sender->sendMessage($sender->getLanguage()->translate(KnownTranslationFactory::commands_generic_usage($target->getUsage())));
Expand All @@ -226,7 +226,7 @@ public function dispatch(CommandSender $sender, string $commandLine) : bool{
return true;
}

$sender->sendMessage(KnownTranslationFactory::pocketmine_command_notFound($sentCommandLabel ?? "", "/help")->prefix(TextFormat::RED));
$sender->sendMessage(KnownTranslationFactory::pocketmine_command_notFound($sentCommandLabel, "/help")->prefix(TextFormat::RED));
return false;
}

Expand Down