當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。