本文整理匯總了PHP中pocketmine\command\PluginCommand::setExecutor方法的典型用法代碼示例。如果您正苦於以下問題:PHP PluginCommand::setExecutor方法的具體用法?PHP PluginCommand::setExecutor怎麽用?PHP PluginCommand::setExecutor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pocketmine\command\PluginCommand
的用法示例。
在下文中一共展示了PluginCommand::setExecutor方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: enableCmd
/**
* Register this class as a command.
*
* @param str $cmd - command to register
* @param mixed[] $yaml - options for command
*/
public function enableCmd($cmd, $yaml)
{
$newCmd = new PluginCommand($cmd, $this->owner);
if (isset($yaml["description"])) {
$newCmd->setDescription($yaml["description"]);
}
if (isset($yaml["usage"])) {
$newCmd->setUsage($yaml["usage"]);
}
if (isset($yaml["aliases"]) and is_array($yaml["aliases"])) {
$aliasList = [];
foreach ($yaml["aliases"] as $alias) {
if (strpos($alias, ":") !== false) {
$this->owner->getLogger()->info("Unable to load alias {$alias}");
continue;
}
$aliasList[] = $alias;
}
$newCmd->setAliases($aliasList);
}
if (isset($yaml["permission"])) {
$newCmd->setPermission($yaml["permission"]);
}
if (isset($yaml["permission-message"])) {
$newCmd->setPermissionMessage($yaml["permission-message"]);
}
$newCmd->setExecutor($this);
$cmdMap = $this->owner->getServer()->getCommandMap();
$cmdMap->register($this->owner->getDescription()->getName(), $newCmd);
}
示例2: onEnable
public function onEnable()
{
$cmd = new PluginCommand("customkick", $this);
$cmd->setDescription("Kick with custom message");
$cmd->setUsage("/kick <player>");
$cmd->setExecutor($this);
$this->getServer()->getCommandMap()->register($this->getDescription()->getName(), $cmd);
}
示例3: registerCommand
public function registerCommand(CommandRegistration $stormCommand)
{
$cmd = new PluginCommand($stormCommand->getName(), $this);
$cmd->setExecutor($stormCommand->getCommandHandler());
$this->getServer()->getCommandMap()->register($this->getDescription()->getName(), $cmd);
}