当前位置: 首页>>代码示例>>PHP>>正文


PHP plugin\Plugin类代码示例

本文整理汇总了PHP中pocketmine\plugin\Plugin的典型用法代码示例。如果您正苦于以下问题:PHP Plugin类的具体用法?PHP Plugin怎么用?PHP Plugin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Plugin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getSimpleAuthData

 public static function getSimpleAuthData(Plugin $plugin, $db = null)
 {
     if (!file_exists($plugin->getDataFolder() . "SimpleAuth/players")) {
         return;
     }
     $config = (new Config($plugin->getDataFolder() . "SimpleAuth/config.yml", Config::YAML))->getAll();
     $provider = $config["dataProvider"];
     switch (strtolower($provider)) {
         case "yaml":
             $plugin->getLogger()->debug("Using YAML data provider");
             $provider = new YAMLDataProvider($plugin);
             break;
         case "sqlite3":
             $plugin->getLogger()->debug("Using SQLite3 data provider");
             $provider = new SQLite3DataProvider($plugin);
             break;
         case "mysql":
             $plugin->getLogger()->debug("Using MySQL data provider");
             $provider = new MySQLDataProvider($plugin);
             break;
         case "none":
         default:
             $provider = new DummyDataProvider($plugin);
             break;
     }
     $folderList = self::getFolderList($plugin->getDataFolder() . "SimpleAuth/players", "folder");
     foreach ($folderList as $alphabet) {
         $ymlList = self::getFolderList($plugin->getDataFolder() . "SimpleAuth/players/" . $alphabet, "file");
         foreach ($ymlList as $ymlName) {
             $yml = (new Config($plugin->getDataFolder() . "SimpleAuth/players/" . $alphabet . "/" . $ymlName, Config::YAML))->getAll();
             $name = explode(".", $ymlName)[0];
             if ($db instanceof PluginData) {
                 $db->addAuthReady(mb_convert_encoding($name, "UTF-8"), $yml["hash"]);
             }
         }
     }
     self::rmdirAll($plugin->getDataFolder() . "SimpleAuth");
 }
开发者ID:RedstoneAlmeida,项目名称:UUIDAuth,代码行数:38,代码来源:SimpleAuthImporter.php

示例2: __construct

 public function __construct(Plugin $plugin)
 {
     $this->plugin = $plugin;
     $config = $this->plugin->getConfig()->get("dataProviderSettings");
     if (!isset($config["host"]) or !isset($config["user"]) or !isset($config["password"]) or !isset($config["database"])) {
         $this->plugin->getLogger()->critical("Invalid MySQL settings");
         $this->plugin->setDataProvider(new DummyDataProvider($this->plugin));
         return;
     }
     $this->database = new \mysqli($config["host"], $config["user"], $config["password"], $config["database"], isset($config["port"]) ? $config["port"] : 3306);
     if ($this->database->connect_error) {
         $this->plugin->getLogger()->critical("Couldn't connect to MySQL: " . $this->database->connect_error);
         $this->plugin->setDataProvider(new DummyDataProvider($this->plugin));
         return;
     }
     $resource = $this->plugin->getResource("mysql.sql");
     $this->database->query(stream_get_contents($resource));
     fclose($resource);
     $this->plugin->getServer()->getScheduler()->scheduleRepeatingTask(new MySQLPingTask($this->plugin, $this->database), 600);
     // Each 30 seconds
     $this->plugin->getLogger()->info("Connected to MySQL server");
 }
开发者ID:RedstoneAlmeida,项目名称:UUIDAuth,代码行数:22,代码来源:MySQLDataProvider.php

示例3: __construct

 public function __construct(Plugin $plugin)
 {
     $this->plugin = $plugin;
     if ($plugin->getServer()->getPluginManager()->getPlugin("SimpleArea") != null) {
         $plugin->getServer()->getPluginManager()->registerEvents($this, $plugin);
     }
 }
开发者ID:EmreTr1,项目名称:rtr,代码行数:7,代码来源:OutEventListner.php

示例4: 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()];
 }
开发者ID:ChalkPE,项目名称:ExamplePlugin,代码行数:12,代码来源:EconomyAPIListener.php

示例5: __construct

 /**
  * @param Plugin      $plugin
  * @param Permissible $permissible
  *
  * @throws PluginException
  */
 public function __construct(Plugin $plugin, Permissible $permissible)
 {
     if (!$plugin->isEnabled()) {
         throw new PluginException("Plugin " . $plugin->getDescription()->getName() . " is disabled");
     }
     $this->permissible = $permissible;
     $this->plugin = $plugin;
 }
开发者ID:zzz1999,项目名称:ImagicalMine,代码行数:14,代码来源:PermissionAttachment.php

示例6: __construct

 public function __construct(Plugin $plugin)
 {
     if ($this->getResultType() !== self::TYPE_RAW and $this->getExpectedColumns() === null) {
         echo "Fatal: Plugin error. ", static::class . " must override getExpectedColumns(), but it didn't. Committing suicide.";
         sleep(604800);
         die;
     }
     $plugin->getServer()->getScheduler()->scheduleAsyncTask($this);
 }
开发者ID:legoboy0215,项目名称:LegionPE-Theta-Base,代码行数:9,代码来源:AsyncQuery.php

示例7: __construct

 public function __construct(Plugin $plugin)
 {
     $this->plugin = $plugin;
     if ($plugin->getServer()->getPluginManager()->getPlugin("EDGE") != null) {
         $plugin->getServer()->getPluginManager()->registerEvents($this, $plugin);
         // $this->edge = EDGE::getInstance ();
         $this->edge = $plugin->getServer()->getPluginManager()->getPlugin("EDGE");
         $this->callback = $this->plugin->getServer()->getScheduler()->scheduleRepeatingTask(new EDGEControlTask($this), 20);
     }
 }
开发者ID:nesgohood,项目名称:PMMP-Plugins,代码行数:10,代码来源:EDGEControl.php

示例8: Execute

 static function Execute(Plugin $owner, $callback, $delay = 1, $mode = 0)
 {
     switch ($mode) {
         case 0:
             return $owner->getServer()->getScheduler()->scheduleDelayedTask(new ExecuteTask($owner, $callback), $delay);
             break;
         case 1:
             return $owner->getServer()->getScheduler()->scheduleRepeatingTask(new ExecuteTask($owner, $callback), $delay);
             break;
     }
 }
开发者ID:GracieWargo,项目名称:PocketMine,代码行数:11,代码来源:ExecuteTask.php

示例9: getCommonVars

 /**
  * If GrabBag is available, try to get a single shared instance of
  * ExpandVars
  */
 public static function getCommonVars(Plugin $owner)
 {
     $pm = $owner->getServer()->getPluginManager();
     if (($gb = $pm->getPlugin("GrabBag")) !== null) {
         if ($gb->isEnabled() && MPMU::apiCheck($gb->getDescription()->getVersion(), "2.3")) {
             $vars = $gb->api->getVars();
             if ($vars instanceof ExpandVars) {
                 return $vars;
             }
         }
     }
     return new ExpandVars($owner);
 }
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:17,代码来源:ExpandVars.php

示例10: execute

 public function execute(CommandSender $sender, $commandLabel, array $args)
 {
     if (!$this->owningPlugin->isEnabled()) {
         return false;
     }
     if (!$this->testPermission($sender)) {
         return false;
     }
     $success = $this->executor->onCommand($sender, $this, $commandLabel, $args);
     if (!$success and $this->usageMessage !== "") {
         $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
     }
     return $success;
 }
开发者ID:xxFlare,项目名称:PocketMine-MP,代码行数:14,代码来源:PluginCommand.php

示例11: execute

 public function execute(CommandSender $sender, $commandLabel, array $args)
 {
     if (!$this->owningPlugin->isEnabled()) {
         return \false;
     }
     if (!$this->testPermission($sender)) {
         return \false;
     }
     $success = $this->executor->onCommand($sender, $this, $commandLabel, $args);
     if (!$success and $this->usageMessage !== "") {
         $sender->sendMessage(TextFormat::RED . "Usage: " . $this->usageMessage);
     }
     return $success;
 }
开发者ID:Edwardthedog2,项目名称:Steadfast2,代码行数:14,代码来源:PluginCommand.php

示例12: prepareData

 private function prepareData(Plugin $plugin, \Exception $e, $event)
 {
     $desc = $plugin->getDescription();
     $sha = false;
     $class = new \ReflectionClass($plugin);
     $file = $class->getProperty("file");
     $file->setAccessible(true);
     $path = $file->getValue($plugin);
     $file->setAccessible(false);
     $path = realpath("{$path}/.git/refs/heads/master");
     if (is_file($path)) {
         $sha = trim(file_get_contents($path));
     }
     $this->payload = serialize(["repo" => "LegendOfMCPE/xEcon", "plugin" => ["name" => $desc->getName(), "version" => $desc->getVersion()], "event" => $event, "exception" => ["class" => get_class($e), "message" => $e->getMessage(), "trace" => $e->getTraceAsString(), "trace-array" => $e->getTrace(), "file" => $e->getFile(), "line" => $e->getLine(), "code" => $e->getCode()], "sha" => $sha]);
 }
开发者ID:MCPEGamerJPatGitHub,项目名称:xEcon,代码行数:15,代码来源:ExceptionReportTask.php

示例13: describeToSender

 private function describeToSender(Plugin $plugin, CommandSender $sender)
 {
     $desc = $plugin->getDescription();
     $sender->sendMessage(TextFormat::DARK_GREEN . $desc->getName() . TextFormat::WHITE . " version " . TextFormat::DARK_GREEN . $desc->getVersion());
     if ($desc->getDescription() != null) {
         $sender->sendMessage($desc->getDescription());
     }
     if ($desc->getWebsite() != null) {
         $sender->sendMessage("Website: " . $desc->getWebsite());
     }
     if (count($authors = $desc->getAuthors()) > 0) {
         if (count($authors) === 1) {
             $sender->sendMessage("Author: " . implode(", ", $authors));
         } else {
             $sender->sendMessage("Authors: " . implode(", ", $authors));
         }
     }
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:18,代码来源:VersionCommand.php

示例14: unregister

 /**
  * @param RegisteredListener|Listener|Plugin $object
  */
 public function unregister($object)
 {
     if ($object instanceof Plugin or $object instanceof Listener) {
         $changed = false;
         foreach ($this->handlerSlots as $priority => $list) {
             foreach ($list as $hash => $listener) {
                 if ($object instanceof Plugin and $listener->getPlugin() === $object or $object instanceof Listener and $listener->getListener() === $object) {
                     unset($this->handlerSlots[$priority][$hash]);
                     $changed = true;
                 }
             }
         }
         if ($changed === true) {
             $this->handlers = null;
         }
     } elseif ($object instanceof RegisteredListener) {
         if (isset($this->handlerSlots[$object->getPriority()][spl_object_hash($object)])) {
             unset($this->handlerSlots[$object->getPriority()][spl_object_hash($object)]);
             $this->handlers = null;
         }
     }
 }
开发者ID:TylerAndrew,项目名称:ClearSky,代码行数:25,代码来源:HandlerList.php

示例15: disablePlugin

 /**
  * @param Plugin $plugin
  */
 public function disablePlugin(Plugin $plugin)
 {
     if ($plugin instanceof PluginBase and $plugin->isEnabled()) {
         MainLogger::getLogger()->info("Disabling " . $plugin->getDescription()->getFullName());
         Server::getInstance()->getPluginManager()->callEvent(new PluginDisableEvent($plugin));
         $plugin->setEnabled(false);
     }
 }
开发者ID:applqpak,项目名称:plugin-remakes,代码行数:11,代码来源:FolderPluginLoader.php


注:本文中的pocketmine\plugin\Plugin类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。