public $kills = []; COnfig Code: --- Steve: kills: 22 ... how do i save that config to $kills[]? on onEnable()
You question isn't very clear, I could asnswe with some random code that will work, but maybe not actually is what you're looking for. So I'll ask: Do you plan saving other stuff than kills, or is the config already in that format and you want to parse it? What should $kills look like? Should it be like $kills["name"] returns the number?
If the current method of saving is exactly like described, and the array has to be exactly like you said, that'll work: (assuming $config is an instance of Config) PHP: foreach ($config->getAll() as $name => $data) { $this->kills[$name] = $data["kills"];}
Ok first show me the code. Try setting your $this->kills = $config->getAll() then var_dump($this->kills) and show the output.
I made a config file exactly like this: Code: --- Steve: kills: 22 Levi: kills: 2 dktapps: kills: 1337 ... Then used this exact code: PHP: public function onEnable(){ $stuff = $this->getConfig()->getAll(); $kills = []; foreach ($stuff as $name => $data) { $kills[$name] = $data["kills"]; } var_dump($kills); } and the result was this console output: Code: array(3) { ["Steve"]=> int(22) ["Levi"]=> int(2) ["dktapps"]=> int(1337) } So there is either something different than how you explained it, or something in your setup doesn't work. Edit: Fixed code blocks
Then $this->kills = $this->getConfig()->getAll() should be enough. Sorry for the late reply, I haven't been reading my alerts for a while.
You can do it with yaml_parse_file, so you won't need to construct config object. PHP: $kills = array();$config = yaml_parse_file($this->getDataFolder() . "kills.yml");foreach($config as $player => $key){ $kills[$player] = $key;}