mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-17 16:15:20 +01:00
Reorder config to the default sections on boot
This commit is contained in:
parent
c011bb6be0
commit
296a27dc63
@ -31,6 +31,7 @@ import com.djrapitops.plugin.utilities.Verify;
|
||||
import javax.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -73,6 +74,10 @@ public abstract class ConfigSystem implements SubSystem {
|
||||
public void enable() throws EnableException {
|
||||
try {
|
||||
copyDefaults();
|
||||
config.reorder(Arrays.asList(
|
||||
"Server", "Network", "Plugin", "Database", "Webserver",
|
||||
"Data_gathering", "Time", "Display_options", "Formatting", "World_aliases", "Export", "Plugins"
|
||||
));
|
||||
config.save();
|
||||
|
||||
if (logger.getDebugLogger() instanceof CombineDebugLogger) {
|
||||
|
@ -192,12 +192,17 @@ public class ConfigNode {
|
||||
Collections.sort(nodeOrder);
|
||||
}
|
||||
|
||||
public boolean reorder(List<String> newOrder) {
|
||||
if (nodeOrder.containsAll(newOrder)) {
|
||||
nodeOrder = newOrder;
|
||||
return true;
|
||||
public void reorder(List<String> newOrder) {
|
||||
List<String> oldOrder = nodeOrder;
|
||||
nodeOrder = new ArrayList<>();
|
||||
for (String key : newOrder) {
|
||||
if (childNodes.containsKey(key)) {
|
||||
nodeOrder.add(key);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
// Add those that were not in the new order, but are in the old order.
|
||||
oldOrder.removeAll(nodeOrder);
|
||||
nodeOrder.addAll(oldOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user