mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Better Auto-Update config loader, still cannot handle multiple options with the exact same name and spacing, but will not break configs anymore in those situations, just mis-comment.
This commit is contained in:
parent
089f3a0e71
commit
001b11efc6
@ -65,6 +65,9 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
|||||||
output = output.substring(output.indexOf('\n', output.indexOf('#')) + 1);
|
output = output.substring(output.indexOf('\n', output.indexOf('#')) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String[] keys = output.split("\n");
|
||||||
|
|
||||||
|
|
||||||
// Read the internal config to get comments, then put them in the new one
|
// Read the internal config to get comments, then put them in the new one
|
||||||
try {
|
try {
|
||||||
// Read internal
|
// Read internal
|
||||||
@ -86,11 +89,15 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
output = "";
|
||||||
// Dump to the new one
|
// Dump to the new one
|
||||||
for (String key : comments.keySet()) {
|
for (String key : keys) {
|
||||||
if (output.contains(key)) {
|
String comment = comments.get(key.substring(0, key.indexOf(":") + 1));
|
||||||
output = output.substring(0, output.indexOf(key)) + comments.get(key) + output.substring(output.indexOf(key));
|
if (comment != null) {
|
||||||
|
output += comment;
|
||||||
}
|
}
|
||||||
|
output += key;
|
||||||
|
output += "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user