本文整理汇总了PHP中pocketmine\utils\Config类的典型用法代码示例。如果您正苦于以下问题:PHP Config类的具体用法?PHP Config怎么用?PHP Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveYml
public function saveYml()
{
ksort($this->nn);
$nn = new Config($this->getServer()->getDataPath() . "/plugins/! MineBlock/" . "NickName.yml", Config::YAML, []);
$nn->setAll($this->nn);
$nn->save();
}
示例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();
}
示例3: saveYml
public function saveYml()
{
$fly = new Config($this->getServer()->getDataPath() . "/plugins/! DeBePlugins/" . "Fly.yml", Config::YAML);
$fly->setAll($this->fly);
$fly->save();
$this->loadYml();
}
示例4: checkUpdate
public function checkUpdate()
{
$this->getPlugin()->getServer()->getPluginManager()->callEvent($event = new UpdateCheckingEvent($this->getPlugin(), $this->channel));
if ($event->isCancelled()) {
return false;
}
if ($this->channel == "beta") {
$address = "https://api.github.com/repos/cybercube-hk/jail/releases";
} else {
$this->plugin->getLogger()->alert("[UPDATER] INVALID CHANNEL!");
return false;
}
$i = json_decode(Utils::getURL($address), true);
if ($this->channel == "beta") {
$i = $i[0];
$this->newversion = substr($i["name"], 6);
$this->dlurl = $i["assets"][0]["browser_download_url"];
}
$plugin = $this->getPlugin();
if ($plugin::VERSION_STRING !== $this->newversion) {
$path = $this->plugin->getDataFolder() . "newest-version-download-link.txt";
echo "\n";
$this->plugin->getLogger()->info("Your version is too old or too new! The latest " . $this->channel . " version is: (version: " . $this->newversion . ")");
$this->plugin->getLogger()->info("Download url for the latest version: §e" . $this->dlurl . "");
$this->plugin->getLogger()->info("The link is being saved into: §bnewest-version-download-link.txt\n");
$txt = new Config($path, Config::ENUM);
$txt->set("Version " . $this->newversion . " -> " . $this->dlurl, true);
$txt->save();
return true;
}
echo "\n";
$this->plugin->getLogger()->info("No updates found! Your Jail version is up-to-date!\n");
return true;
}
示例5: saveYml
public function saveYml()
{
asort($this->si);
$si = new Config($this->getServer()->getDataPath() . "/plugins/! MineBlock/" . "SubInventory.yml", Config::YAML);
$si->setAll($this->si);
$si->save();
}
示例6: setPlayer
public function setPlayer(IPlayer $player, $rank)
{
$fileName = $this->plugin->getDataFolder() . "players/" . strtolower($player->getName()) . ".yml";
$config = new Config($fileName, Config::YAML, ["name" => $player->getName(), "rank" => $rank]);
$config->set("rank", $rank);
$config->save(true);
}
示例7: onRun
public function onRun($currentTick)
{
$config = new Config($this->getOwner()->getDataFolder() . "dispensers.yml", Config::YAML);
$config->setAll($this->getOwner()->getDispenserList());
$config->save();
$this->getOwner()->getLogger()->info(TextFormat::AQUA . "Auto-saved!");
}
示例8: process
public function process()
{
$path = $this->getServer()->getPluginManager()->getPlugin("SimpleAuth")->getDataFolder() . "/players/";
foreach (glob($path . "*/*.yml") as $file) {
$data = new Config($file, Config::YAML);
$pname = trim(strtolower(basename($file, ".yml")));
$regdate = $data->get("registerdate");
$logindate = $data->get("logindate");
$ip = $data->get("lastip");
$hash = $data->get("hash");
/*$this->db->query("UPDATE simpleauth_players SET name =
'" . $pname . "', hash = '" . $hash . "', registerdate = '"
. $regdate ."', logindate = '" . $logindate . "', lastip = '"
. $ip . "' WHERE ");*/
$result = $this->db->query("INSERT INTO simpleauth_players (name, hash, registerdate, logindate, lastip)\n\t\t\t\t\t\t\t\t\t\tVALUES ('{$pname}', '{$hash}', '{$regdate}', '{$logindate}', '{$ip}')");
if ($result) {
$this->users++;
} else {
$this->getServer()->getPluginManager()->disablePlugin($this);
$this->getLogger()->critical("Unable to sumbit user to MySQL Database: Unknown Error. Disabling Plugin...");
}
if ($this->users % 100 === 0) {
$this->getLogger()->notice((string) $this->users . " processed.");
}
}
}
示例9: checkConfig
public function checkConfig()
{
if ($this->version > ConfigUpdater::CONFIG_VERSION) {
$this->tapToDo->getLogger()->warning("The config loaded is not supported. It may not function correctly. ");
}
while ($this->version < ConfigUpdater::CONFIG_VERSION) {
switch ($this->version) {
case 0:
$this->tapToDo->getLogger()->info("Updating config from version 0 to 1...");
$blocks = $this->config->getAll();
foreach ($blocks as $id => $block) {
foreach ($block["commands"] as $i => $command) {
if (strpos($command, "%safe") === false && strpos($command, "%op") === false) {
$command .= "%pow";
}
$block["commands"][$i] = str_replace("%safe", "", $command);
}
$blocks[$id] = $block;
}
unlink($this->tapToDo->getDataFolder() . "blocks.yml");
$this->tapToDo->saveResource("blocks.yml");
$this->config = new Config($this->tapToDo->getDataFolder() . "blocks.yml", Config::YAML);
$this->config->set("version", 1);
$this->config->set("blocks", $blocks);
$this->config->save();
$this->version = 1;
break;
}
}
return $this->config;
}
示例10: cfgSave
/**
* Save a config section to the plugins' config.yml
*
* @param str $key - section to save
* @param mixed $settings - settings to save
*/
public function cfgSave($key, $settings)
{
$cfg = new Config($this->getDataFolder() . "config.yml", Config::YAML);
$dat = $cfg->getAll();
$dat[$key] = $settings;
$cfg->setAll($dat);
$cfg->save();
}
示例11: save
public function save()
{
$config = new Config($this->path . "protects.yml", Config::YAML);
$config->setAll($this->yml);
$config->save();
$config = new Config($this->path . "options.yml", Config::YAML);
$config->setAll($this->option);
$config->save();
}
示例12: onDisable
public function onDisable()
{
$save = new Config($this->getDataFolder() . "GambleDB.yml", Config::YAML);
$save->setAll($this->db);
$save->save();
$save = new Config($this->getDataFolder() . "lotto.yml", Config::YAML);
$save->setAll($this->lotto);
$save->save();
}
示例13: onDisable
public function onDisable()
{
$config = new Config($this->getDataFolder() . "donators.yml", Config::YAML, array());
$config->setAll($this->donators);
$config->save();
$kits = new Config($this->getDataFolder() . "kits.yml", Config::YAML, array());
$kits->setAll($this->kits);
$kits->save();
}
示例14: init
public static function init()
{
if (!file_exists($this->plugin->dataDir . $this->filename . ".yml")) {
$this->plugin->getLogger()->info(TextFormat::RED . "Can't find " . $this->filename . " creating new one !");
$d = new Config($this->plugin->dataDir . $this->filename . ".yml", Config::YAML, array());
$d->save();
return $d;
}
return new Config($this->plugin->dataDir . $this->filename . ".yml", Config::YAML, array());
}
示例15: onDisable
public function onDisable()
{
$save = new Config($this->getDataFolder() . "database.yml", Config::YAML);
$save->setAll($this->db);
$save->save();
if ($this->interlocker->dummyPlayer instanceof DummyPlayer) {
$this->interlocker->dummyPlayer->loggedIn = false;
$this->interlocker->dummyPlayer->close();
}
}