本文整理汇总了PHP中pocketmine\utils\Config::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::save方法的具体用法?PHP Config::save怎么用?PHP Config::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\utils\Config
的用法示例。
在下文中一共展示了Config::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setExempt
/**
* @param Player $player
* @param bool $value
*/
public function setExempt(Player $player, $value = true)
{
if ($value) {
$this->exempts->set(strtolower($player->getName()));
$this->exempts->save();
} else {
$this->exempts->remove(strtolower($player->getName()));
$this->exempts->save();
}
}
示例2: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $sub)
{
@mkdir($this->getServer()->getDataPath() . "/plugins/! DeBePlugins/");
$korean = new Config($this->getServer()->getDataPath() . "/plugins/! DeBePlugins/" . "! Korean.yml", Config::YAML, ["Korean" => false]);
if ($korean->get("Korean")) {
$korean->set("Korean", false);
$m = "설정";
} else {
$korean->set("Korean", true);
$m = "해제";
}
$sender->sendMessage("[Korean] 한국말 {$m}");
$korean->save();
return true;
}
示例3: 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;
}
示例4: saveChests
public function saveChests()
{
$save = [];
foreach ($this->chests as $chest) {
/** @var ChestPattern $pattern */
$pattern = $chest->getPattern();
$save[] = ["x" => $chest->getPosition()->x, "y" => $chest->getPosition()->y, "z" => $chest->getPosition()->z, "levelName" => $chest->getPosition()->getLevel()->getName(), "patternName" => $pattern::getName(), "patternArgs" => $pattern->getPatternData()];
}
$this->config->setAll($save);
$this->config->save();
}
示例5: saveSession
private function saveSession()
{
$values = [];
foreach (self::$configDefaults as $k => $v) {
if ($k !== "mutedUntil") {
$values[$k] = $this->{$k};
} else {
// Use '$this->{$k}' so we can later implement more time handlers without problems...
$values[$k] = $this->{$k} instanceof \DateTime ? $this->{$k}->getTimestamp() : $v;
}
}
$this->config->setAll($values);
$this->config->save();
}
示例6: saveYml
public function saveYml()
{
$fly = new Config($this->getServer()->getDataPath() . "/plugins/! DeBePlugins/" . "Fly.yml", Config::YAML);
$fly->setAll($this->fly);
$fly->save();
$this->loadYml();
}
示例7: 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();
}
示例8: 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);
}
示例9: 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!");
}
示例10: 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;
}
示例11: 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();
}
示例12: onJoin
public function onJoin(PlayerJoinEvent $event)
{
$name = $event->getPlayer()->getDisplayName();
$ip = $event->getPlayer()->getAddress();
if (is_file($this->getDataFolder() . "players/lastip/" . $name[0] . "/" . $name . ".yml")) {
unlink($this->getDataFolder() . "players/lastip/" . $name[0] . "/" . $name . ".yml");
$name = $event->getPlayer()->getDisplayName();
$ip = $event->getPlayer()->getAddress();
@mkdir($this->getDataFolder() . "players/lastip/" . $name[0] . "", 0777, true);
$lastip = new Config($this->getDataFolder() . "players/lastip/" . $name[0] . "/" . $name . ".yml", CONFIG::YAML, array("lastip" => "" . $ip . ""));
$lastip->save();
@mkdir($this->getDataFolder() . "players/ip/" . $ip[0] . "", 0777, true);
$ipfile = new Config($this->getDataFolder() . "players/ip/" . $ip[0] . "/" . $ip . ".txt", CONFIG::ENUM);
$ipfile->set($name);
$ipfile->save();
} else {
$name = $event->getPlayer()->getDisplayName();
$ip = $event->getPlayer()->getAddress();
@mkdir($this->getDataFolder() . "players/lastip/" . $name[0] . "", 0777, true);
$lastip = new Config($this->getDataFolder() . "players/lastip/" . $name[0] . "/" . $name . ".yml", CONFIG::YAML, array("lastip" => "" . $ip . ""));
$lastip->save();
@mkdir($this->getDataFolder() . "players/ip/" . $ip[0] . "", 0777, true);
$ipfile = new Config($this->getDataFolder() . "players/ip/" . $ip[0] . "/" . $ip . ".txt", CONFIG::ENUM);
$ipfile->set($name);
$ipfile->save();
}
}
示例13: save
public function save($path)
{
$name = $this->name;
$data = new Config($path . "{$name}.yml", Config::YAML);
$data->set("name", $name);
$data->set("eid", $this->eid);
$data->set("type", $this->type);
$data->set("networkId", $this->networkId);
$data->set("levelName", $this->levelName);
$data->set("itemOnHand", $this->itemOnHand);
$data->set("armorHelmet", $this->armorHelmet);
$data->set("armorChestplate", $this->armorChestplate);
$data->set("armorLegging", $this->armorLegging);
$data->set("armorBoots", $this->armorBoots);
if ($this->position != null && $this->position != false) {
$data->set("positionX", round($this->position->x));
$data->set("positionY", round($this->position->y));
$data->set("positionZ", round($this->position->z));
}
$data->set("kitBlock", $this->kitBlock);
$data->set("particles", $this->particles);
$data->set("destinationLevelName", $this->destinationLevelName);
if ($this->destinationPos != null && $this->destinationPos != false) {
$data->set("destinationPosX", round($this->destinationPos->x));
$data->set("destinationPosY", round($this->destinationPos->y));
$data->set("destinationPosZ", round($this->destinationPos->z));
}
$data->set("cost", $this->cost);
$data->set("message", $this->message);
$data->set("category", $this->category);
$data->save();
}
示例14: saveInventory
public function saveInventory(Player $player, Inventory $inv)
{
$n = trim(strtolower($player->getName()));
if ($n === "") {
return false;
}
$d = substr($n, 0, 1);
if (!is_dir($this->getDataFolder() . $d)) {
mkdir($this->getDataFolder() . $d);
}
$path = $this->getDataFolder() . $d . "/" . $n . ".yml";
$cfg = new Config($path, Config::YAML);
$yaml = $cfg->getAll();
if ($this->isGlobal) {
$ln = "*";
} else {
$ln = trim(strtolower($player->getLevel()->getName()));
}
$yaml[$ln] = [];
foreach ($inv->getContents() as $slot => &$item) {
$yaml[$ln][$slot] = implode(":", [$item->getId(), $item->getDamage(), $item->getCount()]);
}
$inv->clearAll();
$cfg->setAll($yaml);
$cfg->save();
return true;
}
示例15: 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();
}