diff --git a/src/main/java/com/songoda/ultimatekits/UltimateKits.java b/src/main/java/com/songoda/ultimatekits/UltimateKits.java index 45eb344..13fa41e 100644 --- a/src/main/java/com/songoda/ultimatekits/UltimateKits.java +++ b/src/main/java/com/songoda/ultimatekits/UltimateKits.java @@ -455,6 +455,12 @@ public class UltimateKits extends SongodaPlugin { public void saveKits(boolean force) { if (!loaded && !force) return; + // If we're changing the order the file needs to be wiped. + if (kitManager.hasOrderChanged()) { + kitConfig.clearConfig(true); + kitManager.savedOrderChange(); + } + // Hot fix for kit file resets. if (kitConfig.contains("Kits")) for (String kitName : kitConfig.getConfigurationSection("Kits").getKeys(false)) { diff --git a/src/main/java/com/songoda/ultimatekits/kit/KitManager.java b/src/main/java/com/songoda/ultimatekits/kit/KitManager.java index 75bd4dc..8c310e1 100644 --- a/src/main/java/com/songoda/ultimatekits/kit/KitManager.java +++ b/src/main/java/com/songoda/ultimatekits/kit/KitManager.java @@ -14,6 +14,7 @@ public final class KitManager { private final Map kitsAtLocations = new HashMap<>(); private final List registeredKits = new LinkedList<>(); + private boolean hasOrderChanged = false; public Kit addKit(Kit kit) { if (kit == null) return null; @@ -109,6 +110,14 @@ public final class KitManager { if (action >= 0 && action < registeredKits.size()) Collections.swap(registeredKits, i, action); + hasOrderChanged = true; + } + public boolean hasOrderChanged() { + return hasOrderChanged; + } + + public void savedOrderChange() { + hasOrderChanged = false; } }