Changed save-system
This commit is contained in:
		
							parent
							
								
									ef9643c2ae
								
							
						
					
					
						commit
						5a1c809d89
					
				@ -47,7 +47,8 @@ public class Main extends JavaPlugin {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public void onDisable() {
 | 
					    public void onDisable() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        LinkedBeaconTeleporterManager.saveData();
 | 
					        LinkedBeaconTeleporterManager.writeData();
 | 
				
			||||||
 | 
					        saveData();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        log.info("Plugin deactivated");
 | 
					        log.info("Plugin deactivated");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -71,7 +72,15 @@ public class Main extends JavaPlugin {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static void saveData() {
 | 
					    public static void saveData(){
 | 
				
			||||||
 | 
					        boolean lbtDataChanged = LinkedBeaconTeleporterManager.writeData();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        // Only run save, when data changed
 | 
				
			||||||
 | 
					        if(lbtDataChanged)
 | 
				
			||||||
 | 
					            saveData();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static void saveFiles() {
 | 
				
			||||||
        // data.yml
 | 
					        // data.yml
 | 
				
			||||||
        try{
 | 
					        try{
 | 
				
			||||||
            File dataFile = new File("plugins/"+ plugin.getName() +"/data.yml");
 | 
					            File dataFile = new File("plugins/"+ plugin.getName() +"/data.yml");
 | 
				
			||||||
 | 
				
			|||||||
@ -78,12 +78,12 @@ public class LinkedBeaconTeleporterManager {
 | 
				
			|||||||
            placedLBTsById.put(teleporterId, linkedBeaconTeleporters);
 | 
					            placedLBTsById.put(teleporterId, linkedBeaconTeleporters);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Main.saveData();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Main.log.info("All done!");
 | 
					        Main.log.info("All done!");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static void saveData(){
 | 
					    public static boolean saveData(){
 | 
				
			||||||
        Main.log.info("Saving data..");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Main.data = new YamlConfiguration();
 | 
					        Main.data = new YamlConfiguration();
 | 
				
			||||||
        for(String teleporterId : placedLBTsById.keySet()){
 | 
					        for(String teleporterId : placedLBTsById.keySet()){
 | 
				
			||||||
            List<LinkedBeaconTeleporter> LBTs = placedLBTsById.get(teleporterId);
 | 
					            List<LinkedBeaconTeleporter> LBTs = placedLBTsById.get(teleporterId);
 | 
				
			||||||
@ -100,10 +100,7 @@ public class LinkedBeaconTeleporterManager {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            Main.data.set(teleporterId, dataList);
 | 
					            Main.data.set(teleporterId, dataList);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
        Main.saveData();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Main.log.info("done");
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static void constructAndAddRecipes(){
 | 
					    static void constructAndAddRecipes(){
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user