mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-21 05:50:18 +08: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 javax.inject.Singleton;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,6 +74,10 @@ public abstract class ConfigSystem implements SubSystem {
|
|||||||
public void enable() throws EnableException {
|
public void enable() throws EnableException {
|
||||||
try {
|
try {
|
||||||
copyDefaults();
|
copyDefaults();
|
||||||
|
config.reorder(Arrays.asList(
|
||||||
|
"Server", "Network", "Plugin", "Database", "Webserver",
|
||||||
|
"Data_gathering", "Time", "Display_options", "Formatting", "World_aliases", "Export", "Plugins"
|
||||||
|
));
|
||||||
config.save();
|
config.save();
|
||||||
|
|
||||||
if (logger.getDebugLogger() instanceof CombineDebugLogger) {
|
if (logger.getDebugLogger() instanceof CombineDebugLogger) {
|
||||||
|
@ -192,12 +192,17 @@ public class ConfigNode {
|
|||||||
Collections.sort(nodeOrder);
|
Collections.sort(nodeOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean reorder(List<String> newOrder) {
|
public void reorder(List<String> newOrder) {
|
||||||
if (nodeOrder.containsAll(newOrder)) {
|
List<String> oldOrder = nodeOrder;
|
||||||
nodeOrder = newOrder;
|
nodeOrder = new ArrayList<>();
|
||||||
return true;
|
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