◆ clearCommands()
- Returns
- void
Implements CommandMap.
348 foreach($this->knownCommands as $command){
349 $command->unregister($this);
351 $this->knownCommands = [];
352 $this->setDefaultCommands();
◆ dispatch()
- Parameters
-
- Returns
- bool
Implements CommandMap.
314 $args = explode(
" ", $commandLine);
316 if(count($args) === 0){
320 $sentCommandLabel = strtolower(array_shift($args));
321 $target = $this->
getCommand($sentCommandLabel);
323 if($target === null){
327 $target->timings->startTiming();
329 if($this->server->advancedCommandSelector){
330 $this->dispatchAdvanced($sender, $target, $sentCommandLabel, $args);
332 $target->execute($sender, $sentCommandLabel, $args);
334 }
catch(\Throwable $e){
335 $sender->sendMessage(
new TranslationContainer(
TextFormat::RED .
"%commands.generic.exception"));
336 $this->server->getLogger()->critical($this->server->getLanguage()->translateString(
"pocketmine.command.exception", [$commandLine, (
string) $target, $e->getMessage()]));
337 $logger = $sender->getServer()->getLogger();
338 if(
$logger instanceof MainLogger){
342 $target->timings->stopTiming();
◆ getCommand()
- Parameters
-
- Returns
- null|Command
Implements CommandMap.
361 if(isset($this->knownCommands[$name])){
362 return $this->knownCommands[$name];
◆ getCommands()
◆ register()
register |
( |
|
$fallbackPrefix, |
|
|
Command |
$command, |
|
|
|
$label = null , |
|
|
|
$overrideConfig = false |
|
) |
| |
- Parameters
-
string | $fallbackPrefix | |
Command | $command | |
null | $label | |
bool | $overrideConfig | |
- Returns
- bool
208 $label = $command->getName();
210 $label = strtolower(trim($label));
213 if(!(($this->commandConfig[$label] ?? $this->commandConfig[
"default"] ??
true) or $overrideConfig)){
216 $fallbackPrefix = strtolower(trim($fallbackPrefix));
218 $registered = $this->registerAlias($command,
false, $fallbackPrefix, $label);
220 $aliases = $command->getAliases();
221 foreach($aliases as $index => $alias){
222 if(!$this->registerAlias($command,
true, $fallbackPrefix, $alias)){
223 unset($aliases[$index]);
226 $command->setAliases($aliases);
229 $command->setLabel($fallbackPrefix .
":" . $label);
232 $command->register($this);
◆ registerAll()
registerAll |
( |
|
$fallbackPrefix, |
|
|
array |
$commands |
|
) |
| |
- Parameters
-
string | $fallbackPrefix | |
array | $commands | |
Implements CommandMap.
193 foreach($commands as $command){
194 $this->
register($fallbackPrefix, $command);
◆ registerServerAliases()
registerServerAliases |
( |
| ) |
|
- Returns
- void
380 $values = $this->server->getCommandAliases();
382 foreach($values as $alias => $commandStrings){
383 if(strpos($alias,
":") !==
false or strpos($alias,
" ") !==
false){
384 $this->server->getLogger()->warning($this->server->getLanguage()->translateString(
"pocketmine.command.alias.illegal", [$alias]));
391 foreach($commandStrings as $commandString){
392 $args = explode(
" ", $commandString);
395 if($command === null){
396 if(strlen($bad) > 0){
399 $bad .= $commandString;
401 $targets[] = $commandString;
405 if(strlen($bad) > 0){
406 $this->server->getLogger()->warning($this->server->getLanguage()->translateString(
"pocketmine.command.alias.notFound", [$alias, $bad]));
411 if(count($targets) > 0){
412 $this->knownCommands[strtolower($alias)] =
new FormattedCommandAlias(strtolower($alias), $targets);
414 unset($this->knownCommands[strtolower($alias)]);
◆ $commandConfig
◆ $knownCommands
The documentation for this class was generated from the following file:
- src/pocketmine/command/SimpleCommandMap.php