Preserve order change.

This commit is contained in:
Brianna 2020-09-24 11:09:50 -05:00
parent ec2dcf4463
commit 6225f31669
2 changed files with 15 additions and 0 deletions

View File

@ -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)) {

View File

@ -14,6 +14,7 @@ public final class KitManager {
private final Map<Location, KitBlockData> kitsAtLocations = new HashMap<>();
private final List<Kit> 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;
}
}