Changed save-system

master
Ruakij 4 years ago
parent ef9643c2ae
commit 5a1c809d89

@ -47,7 +47,8 @@ public class Main extends JavaPlugin {
public void onDisable() {
LinkedBeaconTeleporterManager.saveData();
LinkedBeaconTeleporterManager.writeData();
saveData();
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
try{
File dataFile = new File("plugins/"+ plugin.getName() +"/data.yml");

@ -78,12 +78,12 @@ public class LinkedBeaconTeleporterManager {
placedLBTsById.put(teleporterId, linkedBeaconTeleporters);
}
Main.saveData();
Main.log.info("All done!");
}
public static void saveData(){
Main.log.info("Saving data..");
public static boolean saveData(){
Main.data = new YamlConfiguration();
for(String teleporterId : placedLBTsById.keySet()){
List<LinkedBeaconTeleporter> LBTs = placedLBTsById.get(teleporterId);
@ -100,10 +100,7 @@ public class LinkedBeaconTeleporterManager {
Main.data.set(teleporterId, dataList);
}
Main.saveData();
Main.log.info("done");
return true;
}
static void constructAndAddRecipes(){

Loading…
Cancel
Save