mirror of
https://github.com/songoda/UltimateKits.git
synced 2024-11-26 04:05:26 +01:00
Preserve order change.
This commit is contained in:
parent
ec2dcf4463
commit
6225f31669
@ -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)) {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user