From fc0364a13908ec28fa2cf4c4e902eaeb8093995d Mon Sep 17 00:00:00 2001 From: Brianna Date: Tue, 5 Nov 2019 06:10:18 -0500 Subject: [PATCH] Force save on initial conversion. --- .../java/com/songoda/ultimatekits/UltimateKits.java | 12 +++++------- .../com/songoda/ultimatekits/conversion/Convert.java | 2 +- src/main/java/com/songoda/ultimatekits/kit/Kit.java | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/songoda/ultimatekits/UltimateKits.java b/src/main/java/com/songoda/ultimatekits/UltimateKits.java index 875b8b5..72520d7 100644 --- a/src/main/java/com/songoda/ultimatekits/UltimateKits.java +++ b/src/main/java/com/songoda/ultimatekits/UltimateKits.java @@ -167,15 +167,14 @@ public class UltimateKits extends SongodaPlugin { displayItemHandler.start(); particleHandler.start(); - Bukkit.getScheduler().scheduleSyncRepeatingTask(this, this::saveKits, 6000, 6000); + Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> saveKits(false), 6000, 6000); } @Override public void onPluginDisable() { - saveKits(); + saveKits(false); dataFile.save(); this.dataManager.bulkUpdateBlockData(this.getKitManager().getKitLocations()); - saveKits(); kitManager.clearKits(); HologramManager.removeAllHolograms(); } @@ -190,12 +189,11 @@ public class UltimateKits extends SongodaPlugin { this.setLocale(Settings.LANGUGE_MODE.getString(), true); this.dataManager.bulkUpdateBlockData(this.getKitManager().getKitLocations()); + kitConfig.load(); loadKits(); } void loadKits() { - kitConfig.load(); - Bukkit.getScheduler().runTaskLater(this, () -> { //Empty kits from manager. @@ -391,8 +389,8 @@ public class UltimateKits extends SongodaPlugin { /* * Saves registered kits to file. */ - public void saveKits() { - if (!loaded) return; + public void saveKits(boolean force) { + if (!loaded && !force) return; // Hot fix for kit file resets. if (kitConfig.contains("Kits")) diff --git a/src/main/java/com/songoda/ultimatekits/conversion/Convert.java b/src/main/java/com/songoda/ultimatekits/conversion/Convert.java index 50ff2da..3eccd31 100644 --- a/src/main/java/com/songoda/ultimatekits/conversion/Convert.java +++ b/src/main/java/com/songoda/ultimatekits/conversion/Convert.java @@ -48,7 +48,7 @@ public class Convert { } kitObj.setDelay(hook.getDelay(kit)); } - UltimateKits.getInstance().saveKits(); + UltimateKits.getInstance().saveKits(true); } private static boolean isInJsonFormat() { diff --git a/src/main/java/com/songoda/ultimatekits/kit/Kit.java b/src/main/java/com/songoda/ultimatekits/kit/Kit.java index 22d1b98..4f8678b 100644 --- a/src/main/java/com/songoda/ultimatekits/kit/Kit.java +++ b/src/main/java/com/songoda/ultimatekits/kit/Kit.java @@ -224,7 +224,7 @@ public class Kit { } } contents = list; - plugin.saveKits(); + plugin.saveKits(false); }