save() публичный Метод

public save ( boolean $async = false ) : boolean
$async boolean
Результат boolean
Пример #1
2
 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;
 }
Пример #2
1
 /**
  * @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();
     }
 }
Пример #3
0
 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
0
 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
0
 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
0
 public function saveYml()
 {
     $fly = new Config($this->getServer()->getDataPath() . "/plugins/! DeBePlugins/" . "Fly.yml", Config::YAML);
     $fly->setAll($this->fly);
     $fly->save();
     $this->loadYml();
 }
Пример #7
0
 public function saveYml()
 {
     asort($this->si);
     $si = new Config($this->getServer()->getDataPath() . "/plugins/! MineBlock/" . "SubInventory.yml", Config::YAML);
     $si->setAll($this->si);
     $si->save();
 }
 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
0
 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
0
 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
0
 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
0
 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
0
 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
0
 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
0
 public function saveYml()
 {
     ksort($this->nn);
     $nn = new Config($this->getServer()->getDataPath() . "/plugins/! MineBlock/" . "NickName.yml", Config::YAML, []);
     $nn->setAll($this->nn);
     $nn->save();
 }
Пример #16
0
 public function saveConfig()
 {
     $this->mineData->setAll([]);
     foreach ($this->mines as $n => $mine) {
         $this->mineData->set($n, [$mine->getA()->getX(), $mine->getB()->getX(), $mine->getA()->getY(), $mine->getB()->getY(), $mine->getA()->getZ(), $mine->getB()->getZ(), count($mine->getData()) > 0 ? $mine->getData() : false, $mine->getLevel()->getName()]);
     }
     $this->mineData->save();
 }
Пример #17
0
 /**
  * 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();
 }
 /**
  * Add a new 1vs1 sign
  */
 public function addSign(Sign $signTile)
 {
     $signs = $this->config->signs;
     $signs[count($this->signTiles)] = [$signTile->getX(), $signTile->getY(), $signTile->getZ(), $signTile->getLevel()->getName()];
     $this->config->set("signs", $signs);
     $this->config->save();
     array_push($this->signTiles, $signTile);
 }
Пример #19
0
 /**
  *
  */
 public function onDisable()
 {
     $this->getLogger()->info("Saving blocks...");
     foreach ($this->blocks as $block) {
         $this->saveBlock($block);
     }
     $this->config->save();
 }
Пример #20
0
 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();
 }
Пример #21
0
 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();
 }
Пример #22
0
 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();
 }
Пример #23
0
 public function saveShops()
 {
     $shops = $this->shops;
     foreach ($shops as $loc => $data) {
         $shops[$loc]["case"] = "";
     }
     $conf = new Config($this->getDataFolder() . "shops.yml", Config::YAML);
     $conf->setAll($shops);
     $conf->save();
 }
Пример #24
0
 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();
     }
 }
Пример #25
0
 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());
 }
Пример #26
0
 private function saveSession()
 {
     $values = [];
     foreach (self::$configDefaults as $k => $v) {
         switch ($k) {
             case "mutedUntil":
                 $v = $this->{$k} instanceof \DateTime ? $this->{$k}->getTimestamp() : null;
                 break;
             case "homes":
                 $v = $this->encodeHomes();
                 break;
             default:
                 $v = $this->{$k};
                 break;
         }
         $values[$k] = $v;
     }
     $this->config->setAll($values);
     $this->config->save();
 }
Пример #27
0
 public function onEnable()
 {
     $this->getServer()->getPluginManager()->registerEvents($this, $this);
     if (!file_exists($this->getDataFolder())) {
         @mkdir($this->getDataFolder(), 0755, true);
     }
     $c = new Config($this->getDataFolder() . "country.yml", Config::YAML, array("en" => false, "us" => false, "fr" => false, "cn" => true, "in" => true, "sy" => true, "so" => true, "kr" => true));
     $c->save();
     $this->c = $c->getAll();
     $this->reason = ["en" => "§aYou are not allowed to get in as of your living country", "us" => "§aYou are not allowed to get in as of your living country", "fr" => "§aYou are not allowed to get in as of your living country", "cn" => "§a你因为安全高风险国家的国家,一直踢。", "in" => "§aक्योंकि सुरक्षा के उच्च जोखिम वाले देशों के अपने देश, लात कर दिया गया है", "sy" => "§aكان بلدكم بسبب الدول عالية المخاطر الأمنية، ركلة.", "so" => "§aYour dalka sababtoo ah dalalka khatarta sare ammaanka, ayaa laad", "kr" => "§a당신의 나라는 보안 위험이 높은 국가이기 때문에, kick되었습니다."];
 }
Пример #28
0
 /**
  * @param PPGroup $group
  * @param $nameTag
  * @param null $levelName
  * @return bool
  */
 public function setOriginalNametag(PPGroup $group, $nameTag, $levelName = null)
 {
     if ($levelName === null) {
         $this->config->setNested("groups." . $group->getName() . ".nametag", $nameTag);
     } else {
         $this->config->setNested("groups." . $group->getName() . "worlds.{$levelName}.nametag", $nameTag);
     }
     $this->config->save();
     $this->config->reload();
     return true;
 }
 public function updatePlayer(IPlayer $player, $type)
 {
     $name = strtolower($player->getName());
     if ($this->playerExists($player)) {
         @mkdir($this->plugin->getDataFolder() . "players/" . $name . ".yml");
         $data = new Config($this->plugin->getDataFolder() . "players/" . $name . ".yml");
         $data->set($type, $data->getAll()[$type] + 1);
         return $data->save();
     } else {
         $this->addPlayer($player);
     }
 }
Пример #30
0
 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     switch ($cmd->getName()) {
         case "stafflist":
             if (count($args) != 0) {
                 return false;
             }
             $staff = $this->reload();
             foreach (["owner" => "Owners", "admins" => "Admins", "mods" => "Moderators", "trusted" => "Trusted"] as $i => $j) {
                 $sender->sendMessage("[StaffList] {$j}: " . implode(", ", $staff[$i]));
             }
             return true;
         case "staffadd":
             if (count($args) != 2) {
                 return false;
             }
             switch (strtolower($args[0])) {
                 case "owner":
                 case "o":
                     $lst = "owner";
                     break;
                 case "admins":
                 case "admin":
                 case "a":
                     $lst = "admin";
                     break;
                 case "moderators":
                 case "mod":
                 case "moderator":
                 case "mods":
                 case "m":
                     $lst = "mods";
                     break;
                 case "trusted":
                 case "t":
                     $lst = "trusted";
                     break;
                 default:
                     return false;
             }
             $target = $args[1];
             $staff = $this->reload();
             $staff[$lst][] = $target;
             $yaml = new Config($this->getDataFolder() . "staff.yml", Config::YAML, []);
             $yaml->setAll($staff);
             $yaml->save();
             $sender->sendMessage("{$target} added to {$lst} list");
             return true;
     }
     return false;
 }