So I'm trying to make a system that saves each player in its own config. It's creating the Config but not saving any entries. But the problem I have is that its not saving: Code: public void save(){ if(uuid == null){ System.out.println("[SAVINGERROR] File could not be saved: 'uuid == null'"); return; } File file = new File("plugins/"+folder+"/playerdata", uuid+".txt"); if(!file.exists()){ try { file.createNewFile(); } catch (IOException e) { System.out.println("[SAVINGERROR] File could not be saved: '"+e.getMessage()+"'"); return; } } FileConfiguration cfg = YamlConfiguration.loadConfiguration(file); try { cfg.save(file); cfg.load(file); } catch (IOException | InvalidConfigurationException e) { System.out.println("[SAVINGERROR] File could not be saved: '"+e.getMessage()+"'"); return; } } Thanks!
@jebbo You are creating a text document not a yaml document, that could be why, i haven't worked much with individual configs lol
@Gater12 The 'setName' method: Code: public void setName(String s){ FileConfiguration cfg = getFileConfig(uuid); cfg.set("name", s); save(); } The 'getFileConfig' method: Code: public FileConfiguration getFileConfig(String uuid){ File file = new File("plugins/"+folder+"/playerdata", uuid+".yml"); if(!file.exists()){ try { file.createNewFile(); } catch (IOException e) { System.out.println("[SAVINGERROR] File could not be created: '"+e.getMessage()+"'"); return null; } } return YamlConfiguration.loadConfiguration(file); } I think im overseeing something.. xD Thanks.
@jebbo If you want to make player config files easily, you could use the Config class of EnviousAPI. Link in description.