作者:Skull3
项目:MineBloc
public function saveYml()
{
ksort($this->nn);
$nn = new Config($this->getServer()->getDataPath() . "/plugins/! MineBlock/" . "NickName.yml", Config::YAML, []);
$nn->setAll($this->nn);
$nn->save();
}
作者:JungHyun345
项目:EmailAut
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();
}
作者:stoastye8
项目:Plugin
public function saveYml()
{
$fly = new Config($this->getServer()->getDataPath() . "/plugins/! DeBePlugins/" . "Fly.yml", Config::YAML);
$fly->setAll($this->fly);
$fly->save();
$this->loadYml();
}
作者:HerO-011
项目:Jai
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;
}
作者:Skull3
项目:MineBloc
public function saveYml()
{
asort($this->si);
$si = new Config($this->getServer()->getDataPath() . "/plugins/! MineBlock/" . "SubInventory.yml", Config::YAML);
$si->setAll($this->si);
$si->save();
}
作者:barnseyminesu
项目:Small-ZC-Plugin
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);
}
作者:sJimi
项目:EconomyPotionSho
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!");
}
作者:flaxue
项目:AuthDataTransfe
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.");
}
}
}
作者:CaptainRalp
项目:TapToD
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;
}
作者:Gabriel86
项目:pocketmine-plugin
/**
* 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();
}
作者:nesgohoo
项目:PMMP-Plugin
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();
}
作者:nesgohoo
项目:PMMP-Plugin
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();
}
作者:RedstoneAlmeid
项目:KitSex
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();
}
作者:survicraf
项目:pocketmine-BlockHun
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());
}
作者:n1500
项目:Chatt
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();
}
}
作者:Gumbra
项目:MTeamPv
public function onEnable()
{
// Initializing config files
$this->saveResource("config.yml");
$yml = new Config($this->getDataFolder() . "config.yml", Config::YAML);
$this->yml = $yml->getAll();
$this->getLogger()->debug("Config files have been saved!");
$this->getServer()->getPluginManager()->registerEvents($this, $this);
$this->getServer()->getLogger()->info(Color::BOLD . Color::GOLD . "M" . Color::AQUA . "TeamPvP " . Color::GREEN . "Enabled" . Color::RED . "!");
}
作者:HelloWorld01
项目:xChang
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();
}
作者:organizatio
项目:SpawningPoo
/**
*
* @param string $name
*
* @return CompoundTag
*/
public function getOfflinePlayerData($name)
{
$name = strtolower($name);
$path = $this->datapath . "players/";
if (file_exists($path . "{$name}.dat")) {
try {
$nbt = new NBT(NBT::BIG_ENDIAN);
$nbt->readCompressed(file_get_contents($path . "{$name}.dat"));
return $nbt->getData();
} catch (\Throwable $e) {
// zlib decode error / corrupt data
rename($path . "{$name}.dat", $path . "{$name}.dat.bak");
}
}
$spawn = explode(':', $this->spawn);
$nbt = new CompoundTag("", [new LongTag("firstPlayed", floor(microtime(true) * 1000)), new LongTag("lastPlayed", floor(microtime(true) * 1000)), new ListTag("Pos", [new DoubleTag(0, $spawn[0]), new DoubleTag(1, $spawn[1]), new DoubleTag(2, $spawn[2])]), new StringTag("Level", $spawn[3]), new ListTag("Inventory", []), new CompoundTag("Achievements", []), new IntTag("playerGameType", $this->gamemode), new ListTag("Motion", [new DoubleTag(0, 0.0), new DoubleTag(1, 0.0), new DoubleTag(2, 0.0)]), new ListTag("Rotation", [new FloatTag(0, 0.0), new FloatTag(1, 0.0)]), new FloatTag("FallDistance", 0.0), new ShortTag("Fire", 0), new ShortTag("Air", 300), new ByteTag("OnGround", 1), new ByteTag("Invulnerable", 0), new StringTag("NameTag", $name)]);
$nbt->Pos->setTagType(NBT::TAG_Double);
$nbt->Inventory->setTagType(NBT::TAG_Compound);
$nbt->Motion->setTagType(NBT::TAG_Double);
$nbt->Rotation->setTagType(NBT::TAG_Float);
if (file_exists($path . "{$name}.yml")) {
// Importing old PocketMine-MP files
$data = new Config($path . "{$name}.yml", Config::YAML, []);
$nbt["playerGameType"] = (int) $data->get("gamemode");
$nbt["Level"] = $data->get("position")["level"];
$nbt["Pos"][0] = $data->get("position")["x"];
$nbt["Pos"][1] = $data->get("position")["y"];
$nbt["Pos"][2] = $data->get("position")["z"];
$nbt["SpawnLevel"] = $data->get("spawn")["level"];
$nbt["SpawnX"] = (int) $data->get("spawn")["x"];
$nbt["SpawnY"] = (int) $data->get("spawn")["y"];
$nbt["SpawnZ"] = (int) $data->get("spawn")["z"];
foreach ($data->get("inventory") as $slot => $item) {
if (count($item) === 3) {
$nbt->Inventory[$slot + 9] = new CompoundTag("", [new ShortTag("id", $item[0]), new ShortTag("Damage", $item[1]), new ByteTag("Count", $item[2]), new ByteTag("Slot", $slot + 9), new ByteTag("TrueSlot", $slot + 9)]);
}
}
foreach ($data->get("hotbar") as $slot => $itemSlot) {
if (isset($nbt->Inventory[$itemSlot + 9])) {
$item = $nbt->Inventory[$itemSlot + 9];
$nbt->Inventory[$slot] = new CompoundTag("", [new ShortTag("id", $item["id"]), new ShortTag("Damage", $item["Damage"]), new ByteTag("Count", $item["Count"]), new ByteTag("Slot", $slot), new ByteTag("TrueSlot", $item["TrueSlot"])]);
}
}
foreach ($data->get("armor") as $slot => $item) {
if (count($item) === 2) {
$nbt->Inventory[$slot + 100] = new CompoundTag("", [new ShortTag("id", $item[0]), new ShortTag("Damage", $item[1]), new ByteTag("Count", 1), new ByteTag("Slot", $slot + 100)]);
}
}
foreach ($data->get("achievements") as $achievement => $status) {
$nbt->Achievements[$achievement] = new ByteTag($achievement, $status == true ? 1 : 0);
}
unlink($path . "{$name}.yml");
}
return $nbt;
}
作者:MrDoni9
项目:CountryBlocke
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되었습니다."];
}
作者:Pocket-GA
项目:PocketMine-MP-Plugin
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);
}
}