本文整理汇总了PHP中pocketmine\plugin\Plugin::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Plugin::getName方法的具体用法?PHP Plugin::getName怎么用?PHP Plugin::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\plugin\Plugin
的用法示例。
在下文中一共展示了Plugin::getName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
/**
* @param Plugin $plugin
*
* @return EconomyAPIListener
*/
public static function getInstance(Plugin $plugin)
{
if (!isset(self::$instance[$plugin->getName()])) {
self::$instance[$plugin->getName()] = new EconomyAPIListener($plugin);
}
return self::$instance[$plugin->getName()];
}
示例2: registerEvents
/**
* Registers all the events in the given Listener class
*
* @param Listener $listener
* @param Plugin $plugin
*
* @throws PluginException
*/
public function registerEvents(Listener $listener, Plugin $plugin)
{
if (!$plugin->isEnabled()) {
throw new PluginException("Plugin attempted to register " . get_class($listener) . " while not enabled");
}
$reflection = new \ReflectionClass(get_class($listener));
foreach ($reflection->getMethods() as $method) {
if (!$method->isStatic()) {
$priority = EventPriority::NORMAL;
$ignoreCancelled = false;
if (preg_match("/^[\t ]*\\* @priority[\t ]{1,}([a-zA-Z]{1,})/m", (string) $method->getDocComment(), $matches) > 0) {
$matches[1] = strtoupper($matches[1]);
if (defined(EventPriority::class . "::" . $matches[1])) {
$priority = constant(EventPriority::class . "::" . $matches[1]);
}
}
if (preg_match("/^[\t ]*\\* @ignoreCancelled[\t ]{1,}([a-zA-Z]{1,})/m", (string) $method->getDocComment(), $matches) > 0) {
$matches[1] = strtolower($matches[1]);
if ($matches[1] === "false") {
$ignoreCancelled = false;
} elseif ($matches[1] === "true") {
$ignoreCancelled = true;
}
}
$parameters = $method->getParameters();
if (count($parameters) === 1 and $parameters[0]->getClass() instanceof \ReflectionClass and is_subclass_of($parameters[0]->getClass()->getName(), Event::class)) {
$class = $parameters[0]->getClass()->getName();
$reflection = new \ReflectionClass($class);
if (strpos((string) $reflection->getDocComment(), "@deprecated") !== false and $this->server->getProperty("settings.deprecated-verbose", true)) {
$this->server->getLogger()->warning($this->server->getLanguage()->translateString("pocketmine.plugin.deprecatedEvent", [$plugin->getName(), $class, get_class($listener) . "->" . $method->getName() . "()"]));
}
$this->registerEvent($class, $listener, $priority, new MethodEventExecutor($method->getName()), $plugin, $ignoreCancelled);
}
}
}
}
示例3: registerExtension
public function registerExtension(Plugin $extension)
{
array_push($this->extensions, $extension->getName());
}
示例4: registerEvents
/**
* Registers all the events in the given Listener class
*
* @param Listener $listener
* @param Plugin $plugin
*
* @throws PluginException
*/
public function registerEvents(Listener $listener, Plugin $plugin)
{
if (!$plugin->isEnabled()) {
throw new PluginException("Plugin attempted to register " . \get_class($listener) . " while not enabled");
}
$reflection = new \ReflectionClass(\get_class($listener));
foreach ($reflection->getMethods() as $method) {
if (!$method->isStatic()) {
$priority = EventPriority::NORMAL;
$ignoreCancelled = \false;
if (\preg_match("/^[\t ]*\\* @priority[\t ]{1,}([a-zA-Z]{1,})/m", (string) $method->getDocComment(), $matches) > 0) {
$matches[1] = \strtoupper($matches[1]);
if (\defined(EventPriority::class . "::" . $matches[1])) {
$priority = \constant(EventPriority::class . "::" . $matches[1]);
}
}
if (\preg_match("/^[\t ]*\\* @ignoreCancelled[\t ]{1,}([a-zA-Z]{1,})/m", (string) $method->getDocComment(), $matches) > 0) {
$matches[1] = \strtolower($matches[1]);
if ($matches[1] === "false") {
$ignoreCancelled = \false;
} elseif ($matches[1] === "true") {
$ignoreCancelled = \true;
}
}
$parameters = $method->getParameters();
if (\count($parameters) === 1 and $parameters[0]->getClass() instanceof \ReflectionClass and \is_subclass_of($parameters[0]->getClass()->getName(), Event::class)) {
$class = $parameters[0]->getClass()->getName();
$reflection = new \ReflectionClass($class);
if (\strpos((string) $reflection->getDocComment(), "@deprecated") !== \false and $this->server->getProperty("settings.deprecated-verbose", \true)) {
$this->server->getLogger()->warning('Plugin ' . $plugin->getName() . ' has registered a listener for ' . $class . ' on method ' . \get_class($listener) . '->' . $method->getName() . '(), but the event is Deprecated.');
}
$this->registerEvent($class, $listener, $priority, new MethodEventExecutor($method->getName()), $plugin, $ignoreCancelled);
}
}
}
}
示例5: __construct
/**
* @param Plugin $owner
* @param str $callable method from $owner to call
* @param array $args arguments to pass to callback method
*/
public function __construct(Plugin $owner, $callable, array $args = [])
{
$this->owner = $owner->getName();
$this->callable = $callable;
$this->args = $args;
}
示例6: registerEvents
/**
* Registers all the events in the given Listener class
*
* @param Listener $listener
* @param Plugin $plugin
*
* @throws \Exception
*/
public function registerEvents(Listener $listener, Plugin $plugin)
{
if (!$plugin->isEnabled()) {
throw new \Exception("Plugin attempted to register " . get_class($listener) . " while not enabled");
}
$reflection = new \ReflectionClass(get_class($listener));
foreach ($reflection->getMethods() as $method) {
if (!$method->isStatic()) {
$priority = EventPriority::NORMAL;
$ignoreCancelled = false;
if (preg_match("/^[\t ]*\\* @priority[\t ]{1,}([a-zA-Z]{1,})\$/m", (string) $method->getDocComment(), $matches) > 0) {
$matches[1] = strtoupper($matches[1]);
if (defined("pocketmine\\event\\EventPriority::" . $matches[1])) {
$priority = constant("pocketmine\\event\\EventPriority::" . $matches[1]);
}
}
if (preg_match("/^[\t ]*\\* @ignoreCancelled[\t ]{1,}([a-zA-Z]{1,})\$/m", (string) $method->getDocComment(), $matches) > 0) {
$matches[1] = strtolower($matches[1]);
if ($matches[1] === "false") {
$ignoreCancelled = false;
} elseif ($matches[1] === "true") {
$ignoreCancelled = true;
}
}
$parameters = $method->getParameters();
if (count($parameters) === 1 and $parameters[0]->getClass() instanceof \ReflectionClass and is_subclass_of($parameters[0]->getClass()->getName(), "pocketmine\\event\\Event")) {
$class = $parameters[0]->getClass()->getName();
$reflection = new \ReflectionClass($class);
if (preg_match("/^[\t ]*\\* @deprecated[\t ]{1,}\$/m", (string) $reflection->getDocComment(), $matches) > 0 and $this->server->getProperty("settings.deprecated-verbose", true)) {
$this->server->getLogger()->warning('"' . $plugin->getName() . '" has registered a listener for ' . $class . ' on method "' . get_class($listener) . '::' . $method . ', but the event is Deprecated.');
}
$this->registerEvent($class, $listener, $priority, new MethodEventExecutor($method->getName()), $plugin, $ignoreCancelled);
}
}
}
}
示例7: cmdCmds
private function cmdCmds(CommandSender $c, Plugin $p, $pageNumber)
{
$desc = $p->getDescription();
$cmds = $desc->getCommands();
if (count($cmds) == 0) {
$c->sendMessage(TextFormat::RED, mc::_("%1% has no configured commands", $p->getName()));
return true;
}
$txt = [];
$txt[] = TextFormat::AQUA . mc::_("Plugin: %1%", $desc->getFullName());
foreach ($cmds as $i => $j) {
$d = isset($j["description"]) ? $j["description"] : "";
$txt[] = TextFormat::GREEN . $i . ": " . TextFormat::WHITE . $d;
}
return $this->paginateText($c, $pageNumber, $txt);
}