View difference between Paste ID: kt54Rsi5 and f5dxeKyU
SHOW: | | - or go back to the newest paste.
1
public class PluginData {
2
3
    @Getter
4
    private static final MessageUtil messageUtil = new MessageUtil();
5
6
	//permanently store the file as it is needed for load and save
7-
	private static File projectFile = new File(ProjectPlugin.getInstance().getDataFolder(),"projectData.yml");
7+
	private static File projectFolder = new File(ProjectPlugin.getInstance().getDataFolder(),"projects");
8
9
    @Getter
10
    private final static Map<String, ProjectData> projectdata = new HashMap<>();
11
12
    public void onSave() throws IOException {
13
14-
		//create a configuration to store the data in
14+
15-
		YamlConfiguration config = new YamlConfiguration();
15+
16
			
17
			//create a file object
18
			File projectFile = new File(projectFolder, projectName+".yml");
19-
			//create a config section for the project data
19+
20-
			ConfigurationSection section = config.createConfigurationSection(projectName);
20+
21
			projectdata.get(projectName).save(projectFile);
22
23-
			projectdata.get(projectName).save(section);
23+
24
		
25
	
26
    }
27-
		//save the configuration to file
27+
28-
		config.save(file);
28+
29
		
30
		//clear old data in case of a reload
31
		projectData.clear();
32
33
        for (File projectFile : projectFolder.listFiles()) {
34
35
			//create a new ProjectData object from the data in the file and put it in the projectData map
36
           projectData.put(name, new ProjectData(file);
37-
		//create a configuration to store the data in
37+
38-
		YamlConfiguration config = new YamlConfiguration();
38+
39
    }
40-
		//load the data from file
40+
41-
		config.load(file);
41+