GenisysPro  for Minecraft PE/Windows 10 v1.1.x
Feature-rich server software for Minecraft PE and Windows 10 Edition
FormattedCommandAlias Class Reference

Public Member Functions

 __construct ($alias, array $formatStrings)
 
 execute (CommandSender $sender, $commandLabel, array $args)
 
- Public Member Functions inherited from Command
 __construct ($name, $description="", $usageMessage=null, array $aliases=[])
 
 getDefaultCommandData ()
 
 generateCustomCommandData (Player $player)
 
 getOverloads ()
 
 execute (CommandSender $sender, $commandLabel, array $args)
 
 getName ()
 
 getPermission ()
 
 setPermission ($permission)
 
 testPermission (CommandSender $target)
 
 testPermissionSilent (CommandSender $target)
 
 getLabel ()
 
 setLabel ($name)
 
 register (CommandMap $commandMap)
 
 unregister (CommandMap $commandMap)
 
 isRegistered ()
 
 getAliases ()
 
 getPermissionMessage ()
 
 getDescription ()
 
 getUsage ()
 
 setAliases (array $aliases)
 
 setDescription ($description)
 
 setPermissionMessage ($permissionMessage)
 
 setUsage ($usage)
 
 __toString ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Command
static generateDefaultData ()
 
static broadcastCommandMessage (CommandSender $source, $message, $sendToSource=true)
 
- Data Fields inherited from Command
 $timings
 
- Protected Attributes inherited from Command
 $commandData = null
 
 $description = ""
 
 $usageMessage
 

Constructor & Destructor Documentation

◆ __construct()

__construct (   $alias,
array  $formatStrings 
)
Parameters
string$alias
string[]$formatStrings
36  {
37  parent::__construct($alias);
38  $this->formatStrings = $formatStrings;
39  }

Member Function Documentation

◆ execute()

execute ( CommandSender  $sender,
  $commandLabel,
array  $args 
)
Parameters
CommandSender$sender
string$commandLabel
array$args
Returns
bool
48  {
49 
50  $commands = [];
51  $result = false;
52 
53  foreach($this->formatStrings as $formatString){
54  try{
55  $commands[] = $this->buildCommand($formatString, $args);
56  }catch(\Throwable $e){
57  if($e instanceof \InvalidArgumentException){
58  $sender->sendMessage(TextFormat::RED . $e->getMessage());
59  }else{
60  $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.exception"));
61  $logger = $sender->getServer()->getLogger();
62  if($logger instanceof MainLogger){
63  $logger->logException($e);
64  }
65  }
66 
67  return false;
68  }
69  }
70 
71  foreach($commands as $command){
72  $result |= Server::getInstance()->dispatchCommand($sender, $command);
73  }
74 
75  return (bool) $result;
76  }

The documentation for this class was generated from the following file: