getName() public method

public getName ( )
コード例 #1
0
 /**
  * @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
0
 /**
  * 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);
             }
         }
     }
 }
 public function registerExtension(Plugin $extension)
 {
     array_push($this->extensions, $extension->getName());
 }
コード例 #4
0
 /**
  * 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
0
 /**
  * @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
0
 /**
  * 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
0
 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);
 }