Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PluginData {
- @Getter
- private static final MessageUtil messageUtil = new MessageUtil();
- //permanently store the file as it is needed for load and save
- private static File projectFolder = new File(ProjectPlugin.getInstance().getDataFolder(),"projects");
- @Getter
- private final static Map<String, ProjectData> projectdata = new HashMap<>();
- public void onSave() throws IOException {
- for (String projectName : projectdata.keySet()) {
- //create a file object
- File projectFile = new File(projectFolder, projectName+".yml");
- //save the project data to that section
- projectdata.get(projectName).save(projectFile);
- }
- }
- public void onLoad() throws IOException, FileNotFoundException, InvalidConfigurationException {
- //clear old data in case of a reload
- projectData.clear();
- for (File projectFile : projectFolder.listFiles()) {
- //create a new ProjectData object from the data in the file and put it in the projectData map
- projectData.put(name, new ProjectData(file);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement