當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Plugin::getDataFolder方法代碼示例

本文整理匯總了PHP中pocketmine\plugin\Plugin::getDataFolder方法的典型用法代碼示例。如果您正苦於以下問題:PHP Plugin::getDataFolder方法的具體用法?PHP Plugin::getDataFolder怎麽用?PHP Plugin::getDataFolder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pocketmine\plugin\Plugin的用法示例。


在下文中一共展示了Plugin::getDataFolder方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: savePlayer

 public function savePlayer(IPlayer $player, array $config)
 {
     $name = trim(strtolower($player->getName()));
     $data = new Config($this->plugin->getDataFolder() . "players/" . $name[0] . "/{$name}.yml", Config::YAML);
     $data->setAll($config);
     $data->save();
 }
開發者ID:RedstoneAlmeida,項目名稱:UUIDAuth,代碼行數:7,代碼來源:YAMLDataProvider.php

示例3: LoadConfig

 public function LoadConfig()
 {
     $this->plugin->saveResource("config.yml");
     $this->config = (new Config($this->plugin->getDataFolder() . "config.yml", Config::YAML))->getAll();
 }
開發者ID:organization,項目名稱:SimpleLogin,代碼行數:5,代碼來源:PluginData.php

示例4: cmdFeatures

 private function cmdFeatures(CommandSender $c, Plugin $plugin, $mgr, $args, $pageNumber)
 {
     //
     $cfgfile = $plugin->getDataFolder() . "config.yml";
     if (!file_exists($cfgfile)) {
         $c->sendMessage(mc::_("%1%: Does not have config.yml", $plugin->getDescription()->getFullName()));
         return true;
     }
     $cfg = (new Config($cfgfile, Config::YAML, []))->getAll();
     $section = "features";
     if (!isset($cfg[$section]) || !is_array($cfg[$section])) {
         $c->sendMessage(mc::_("%1%: Does not have compatible config.yml", $plugin->getDescription()->getFullName()));
         return true;
     }
     if (count($args) == 0) {
         $txt = [];
         $txt[] = mc::_("%1% Features", $plugin->getDescription()->getFullName());
         foreach ($cfg[$section] as $a => $b) {
             if (is_bool($b)) {
                 $txt[] = TextFormat::AQUA . $a . TextFormat::WHITE . ": " . ($b ? TextFormat::GREEN . mc::_("yes") : TextFormat::YELLOW . mc::_("no"));
                 if (isset($cfg[$section]["# " . $b])) {
                     $txt[] = TextFormat::BLUE . "    " . $cfg[$section]["# " . $b];
                 }
             }
         }
         return $this->paginateText($c, $pageNumber, $txt);
     }
     $bounce = false;
     foreach ($args as $i) {
         $v = true;
         if ($i[0] == "+") {
             $i = substr($i, 1);
         } elseif ($i[0] == "-") {
             $v = false;
             $i = substr($i, 1);
         }
         if (!isset($cfg[$section][$i]) || !is_bool($cfg[$section][$i])) {
             $c->sendMessage(mc::_("%1%: Does not support feature %2%", $plugin->getDescription()->getFullName(), $i));
             continue;
         }
         if ($cfg[$section][$i] === $v) {
             continue;
         }
         $cfg[$section][$i] = $v;
         if ($v) {
             $c->sendMessage(mc::_("Enabling %1%", $i));
         } else {
             $c->sendMessage(mc::_("Disabling %1%", $i));
         }
         $bounce = true;
     }
     if (!$bounce) {
         $c->sendMessage(mc::_("No changes"));
         return true;
     }
     $yaml = new Config($cfgfile, Config::YAML, []);
     $yaml->setAll($cfg);
     $yaml->save();
     $mgr->disablePlugin($plugin);
     $mgr->enablePlugin($plugin);
     $c->sendMessage(TextFormat::GREEN . mc::_("Plugin %1% reloaded", $plugin->getDescription()->getFullName()));
     return true;
 }
開發者ID:DWWf,項目名稱:pocketmine-plugins,代碼行數:63,代碼來源:CmdPluginMgr.php


注:本文中的pocketmine\plugin\Plugin::getDataFolder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。