◆ __construct()
__construct |
( |
|
$name, |
|
|
|
$description = "" , |
|
|
|
$usageMessage = null , |
|
|
array |
$aliases = [] |
|
) |
| |
- Parameters
-
string | $name | |
string | $description | |
string | $usageMessage | |
| string[] | $aliases |
82 $this->commandData = self::generateDefaultData();
83 $this->name = $this->nextLabel = $this->label = $name;
87 $this->timings =
new TimingsHandler(
"** Command: " . $name);
◆ __toString()
◆ broadcastCommandMessage()
static broadcastCommandMessage |
( |
CommandSender |
$source, |
|
|
|
$message, |
|
|
|
$sendToSource = true |
|
) |
| |
|
static |
- Parameters
-
351 if($message instanceof TextContainer){
353 $result =
"[" . $source->getName() .
": " . ($source->getServer()->getLanguage()->get($m->getText()) !== $m->getText() ?
"%" :
"") . $m->getText() .
"]";
358 $m->setText($result);
360 $m->setText($colored);
364 $result =
new TranslationContainer(
"chat.type.admin", [$source->getName(), $message]);
368 if($sendToSource ===
true and !($source instanceof ConsoleCommandSender)){
369 $source->sendMessage($message);
372 foreach($users as $user){
373 if($user instanceof CommandSender){
374 if($user instanceof ConsoleCommandSender){
375 $user->sendMessage($result);
376 }elseif($user !== $source){
377 $user->sendMessage($colored);
◆ execute()
◆ generateCustomCommandData()
generateCustomCommandData |
( |
Player |
$player | ) |
|
Generates modified command data for the specified player for AvailableCommandsPacket.
- Parameters
-
- Returns
- |null
◆ generateDefaultData()
static generateDefaultData |
( |
| ) |
|
|
staticfinal |
- Returns
339 if(self::$defaultDataTemplate === null){
340 self::$defaultDataTemplate = json_decode(file_get_contents(
Server::getInstance()->getFilePath() .
"src/pocketmine/resources/command_default.json"));
342 return clone self::$defaultDataTemplate;
◆ getAliases()
- Returns
- string[]
280 return $this->activeAliases;
◆ getDefaultCommandData()
getDefaultCommandData |
( |
| ) |
|
Returns an containing command data
- Returns
◆ getDescription()
- Returns
- string
294 return $this->commandData->description;
◆ getLabel()
◆ getName()
◆ getOverloads()
- Returns
126 return $this->commandData->overloads;
◆ getPermission()
- Returns
- string
149 return $this->commandData->pocketminePermission ?? null;
◆ getPermissionMessage()
- Returns
- string
287 return $this->permissionMessage;
◆ getUsage()
◆ isRegistered()
- Returns
- bool
273 return $this->commandMap !== null;
◆ register()
Registers the command into a Command map
- Parameters
-
- Returns
- bool
234 if($this->allowChangesFrom($commandMap)){
235 $this->commandMap = $commandMap;
◆ setAliases()
setAliases |
( |
array |
$aliases | ) |
|
- Parameters
-
308 $this->commandData->aliases = $aliases;
310 $this->activeAliases = (array) $aliases;
◆ setDescription()
setDescription |
( |
|
$description | ) |
|
◆ setLabel()
- Parameters
-
- Returns
- bool
215 $this->nextLabel = $name;
217 $this->timings =
new TimingsHandler(
"** Command: " . $name);
218 $this->label = $name;
◆ setPermission()
setPermission |
( |
|
$permission | ) |
|
- Parameters
-
157 if($permission !== null){
158 $this->commandData->pocketminePermission = $permission;
160 unset($this->commandData->pocketminePermission);
◆ setPermissionMessage()
setPermissionMessage |
( |
|
$permissionMessage | ) |
|
- Parameters
-
325 $this->permissionMessage = $permissionMessage;
◆ setUsage()
- Parameters
-
332 $this->usageMessage = $usage;
◆ testPermission()
- Parameters
-
- Returns
- bool
174 if($this->permissionMessage === null){
175 $target->sendMessage(
new TranslationContainer(
TextFormat::RED .
"%commands.generic.permission"));
176 }elseif($this->permissionMessage !==
""){
177 $target->sendMessage(str_replace(
"<permission>", $this->
getPermission(), $this->permissionMessage));
◆ testPermissionSilent()
- Parameters
-
- Returns
- bool
189 if(($perm = $this->
getPermission()) === null or $perm ===
""){
193 foreach(explode(
";", $perm) as $permission){
194 if($target->hasPermission($permission)){
◆ unregister()
- Parameters
-
- Returns
- bool
249 if($this->allowChangesFrom($commandMap)){
250 $this->commandMap = null;
251 $this->activeAliases = $this->commandData->aliases;
252 $this->label = $this->nextLabel;
◆ $commandData
◆ $description
◆ $timings
◆ $usageMessage
The documentation for this class was generated from the following file:
- src/pocketmine/command/Command.php