diff --git a/src/main/java/com/graywolf336/jail/JailIO.java b/src/main/java/com/graywolf336/jail/JailIO.java index 84347e9..4ec3207 100644 --- a/src/main/java/com/graywolf336/jail/JailIO.java +++ b/src/main/java/com/graywolf336/jail/JailIO.java @@ -643,6 +643,21 @@ public class JailIO { pl.getLogger().severe("Failed to load the jail " + j.getName() + " as the world '" + j.getWorldName() + "' does not exist (is null). Did you remove this world?"); } + /** Saves everything about a jail, don't usually call this. */ + public void saveEverything() { + long st = System.currentTimeMillis(); + + for(Jail j : pl.getJailManager().getJails()) { + saveJail(j); + + for(Cell c : j.getCells()) { + saveCell(j, c); + } + } + + pl.debug("Saving everything took " + (System.currentTimeMillis() - st) + " millis."); + } + /** * Saves the provided {@link Jail jail} to the storage system we are using. * diff --git a/src/main/java/com/graywolf336/jail/JailMain.java b/src/main/java/com/graywolf336/jail/JailMain.java index 0d016d7..8834a39 100644 --- a/src/main/java/com/graywolf336/jail/JailMain.java +++ b/src/main/java/com/graywolf336/jail/JailMain.java @@ -51,8 +51,8 @@ public class JailMain extends JavaPlugin { //Try to load the old stuff before we load anything, esp the storage stuff LegacyManager lm = new LegacyManager(this); if(lm.doWeNeedToConvert()) { - boolean converted = lm.convertOldData(); - if(!converted) getLogger().severe("We was unable to convert some, or all, of the old data."); + lm.convertOldData(); + if(!lm.wasAnythingConverted()) getLogger().severe("We was unable to convert some, or all, of the old data."); } io = new JailIO(this); @@ -67,6 +67,11 @@ public class JailMain extends JavaPlugin { io.loadJails(); + //If we converted something, let's save EVERYTHING including the cells + if(lm.wasAnythingConverted()) { + io.saveEverything(); + } + cmdHand = new CommandHandler(this); jh = new JailHandler(this); pm = new PrisonerManager(this); diff --git a/src/main/java/com/graywolf336/jail/legacy/LegacyManager.java b/src/main/java/com/graywolf336/jail/legacy/LegacyManager.java index 23bfcad..dca7270 100644 --- a/src/main/java/com/graywolf336/jail/legacy/LegacyManager.java +++ b/src/main/java/com/graywolf336/jail/legacy/LegacyManager.java @@ -27,9 +27,11 @@ import com.graywolf336.jail.enums.Settings; public class LegacyManager { private JailMain pl; private YamlConfiguration global; + private boolean wasConverted; public LegacyManager(JailMain plugin) { this.pl = plugin; + this.wasConverted = false; } /** Returns true/false if the old config, global.yml, exists and needs to be converted. */ @@ -37,6 +39,15 @@ public class LegacyManager { return new File(pl.getDataFolder(), "global.yml").exists(); } + /** + * Returns true if we converted anything and it was successful. + * + * @return true if everything converted successfully, was if not. + */ + public boolean wasAnythingConverted() { + return this.wasConverted; + } + public boolean convertOldData() { File f = new File(pl.getDataFolder(), "global.yml"); @@ -64,6 +75,7 @@ public class LegacyManager { loadOldConfig(); loadOldData(); moveOldConfigs(); + this.wasConverted = true; pl.getLogger().info("...finished converting configs and data."); return true; }catch (Exception e) {