diff --git a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/Main.java b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/Main.java index e1f9ecf..a5b4e2e 100644 --- a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/Main.java +++ b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/Main.java @@ -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"); diff --git a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterManager.java b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterManager.java index 124baaf..4c6256e 100644 --- a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterManager.java +++ b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterManager.java @@ -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 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(){