How do accses a file this is my code and i would like to know how to get players file and change it i would like to change only the players config for example he dies or gets a kill PHP: <?phpdeclare(strict_types=1);namespace besher\PlayerStats;use pocketmine\plugin\PluginBase;use pocketmine\event\Listener;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\utils\Config;use pocketmine\event\player\PlayerDeathEvent;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\Player;class Main extends PluginBase implements Listener{ public function onEnable(){ @mkdir($this->getDataFolder() . "stats/"); $this->getServer()->getPluginManager()->registerEvents($this, $this); } public function onCommand(CommandSender $sender, Command $cmd, String $label, array $args) : bool{ switch($cmd->getName()){ case "stats": global $reciver; $reciver = $this->getServer()->getPlayer($args[0]); $this->profile($sender); } return true; } public function onJoin(PlayerJoinEvent $e) { $player = $e->getPlayer(); $name = $player->getName(); $this->cfg = new Config($this->getDataFolder() . "stats/" . strtolower($player->getName()), Config::YAML, array( "Name" => "$name", "Deaths" => 0, "Kills" => 0, "Jumps" => 0 )); $this->cfg; } public function onDeath(PlayerDeathEvent $e) { $player = $e->getPlayer(); $this->cfg->set("Deaths", $this->cfg->get("Deaths") + 1); $this->cfg->save(); } public function onKill(PlayerDeathEvent $e){ $cause = $e->getEntity()->getLastDamageCause(); if($cause instanceof EntityDamageEntityEvent){ $killer = $cause->getDamager(); if($killer instanceof Player){ $this->cfg->set("Kills", $this->cfg->get("Kills") + 1); $this->cfg->save(); } } } public function profile($player){ $form = $this->getServer()->getPluginManager()->getPlugin("FormAPI")->createSimpleForm(function (Player $player, int $data = null){ if($data === null){ return true; } }); $form->setTitle("§l§2YOUR STATS"); global $reciver; $form->setContent("Player Stats: " . $reciver->getName() . "\nDeaths: " $form->addButton("Exit"); $form->sendToPlayer($player); return $form; }}
Thats already the way, to store the config instances separately, store and retrieve using $this->cfg[$player->getId()]