So I want to create a config with a player name like : cupidonsauce173.yml and in it it would be like that name = cupidonsauce173 fakename = [] I have some issues with getting the fakename to change the DisplayName of the player. it's with /setfakename <fakename> PHP: public function getFakeName(IPlayer $player, $onUpdate = false) { $name = $player->getName(); if($onUpdate === true) { if(!file_exists($this->userDataFolder . strtolower($name) . ".yml")) { return new Config($this->userDataFolder . strtolower($name) . ".yml", Config::YAML, [ "name" => $name, "fakename" => [], ]); } else { return new Config($this->userDataFolder . strtolower($name) . ".yml", Config::YAML, [ ]); } } else { if(file_exists($this->userDataFolder . strtolower($name) . ".yml")) { return new Config($this->userDataFolder . strtolower($name) . ".yml", Config::YAML, [ ]); } else { return [ "name" => $name, "fakename" => [], ]; } } } But I am not sure how to get "name" and "nick" from the config file. If someone could help it would be good. PHP: case "setfakename": if(!$sender instanceof Player) { $sender->sendMessage(TextFormat::RED . " This command can be only used in-game."); return true; } if(!isset($args[0])) { $sender->sendMessage(TextFormat::GREEN . "Usage: /setfakename <fakename>"); return true; } $fakename = str_replace("{BLANK}", ' ', implode('', $args)); $sender->setDisplayName($fakename); $sender->sendMessage(TextFormat::GREEN . " You set your fakename to " . $fakename . "."); break; I mean, I want to make it so when the player do /setfakename <fakename> it will change the [] in config for the args that he put and then save it.
getFakeName returns the config in one case and an array in the other.. If it would only return a config, you could use $config= $this->getFakeName(); $config->set("name", $fakename); and save the config afterwards with $config->save();