Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 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.    
  15.         for (String projectName : projectdata.keySet()) {
  16.            
  17.             //create a file object
  18.             File projectFile = new File(projectFolder, projectName+".yml");
  19.  
  20.             //save the project data to that section
  21.             projectdata.get(projectName).save(projectFile);
  22.  
  23.         }
  24.        
  25.    
  26.     }
  27.  
  28.     public void onLoad() throws IOException, FileNotFoundException, InvalidConfigurationException {
  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.         }
  38.  
  39.     }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement