当前位置: 首页>>代码示例>>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;未经允许,请勿转载。