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"); }
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(); }
public function LoadConfig() { $this->plugin->saveResource("config.yml"); $this->config = (new Config($this->plugin->getDataFolder() . "config.yml", Config::YAML))->getAll(); }
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; }