diff --git a/providers/yaml/src/main/java/cc/carm/lib/configuration/source/yaml/YAMLSource.java b/providers/yaml/src/main/java/cc/carm/lib/configuration/source/yaml/YAMLSource.java index d741243..0381923 100644 --- a/providers/yaml/src/main/java/cc/carm/lib/configuration/source/yaml/YAMLSource.java +++ b/providers/yaml/src/main/java/cc/carm/lib/configuration/source/yaml/YAMLSource.java @@ -104,17 +104,10 @@ public class YAMLSource extends FileConfigSource, YAMLS public String saveToString(ConfigureSection section) { MappingNode mappingNode = this.toNodeTree(section); StringWriter writer = new StringWriter(); - if ((mappingNode.getBlockComments() == null || mappingNode.getBlockComments().isEmpty()) - && (mappingNode.getEndComments() == null || mappingNode.getEndComments().isEmpty()) - && (mappingNode.getInLineComments() == null || mappingNode.getInLineComments().isEmpty()) - && mappingNode.getValue().isEmpty()) { - writer.write(""); - } else { - if (mappingNode.getValue().isEmpty()) { - mappingNode.setFlowStyle(DumperOptions.FlowStyle.FLOW); - } - this.yaml.serialize(mappingNode, writer); + if (mappingNode.getValue().isEmpty()) { + mappingNode.setFlowStyle(DumperOptions.FlowStyle.FLOW); } + this.yaml.serialize(mappingNode, writer); return writer.toString(); } @@ -150,6 +143,7 @@ public class YAMLSource extends FileConfigSource, YAMLS } if (mappingNode == null) return MemorySection.root(this); + Map map = new LinkedHashMap<>(); this.constructMap(mappingNode, map); return MemorySection.root(this, map); @@ -203,7 +197,7 @@ public class YAMLSource extends FileConfigSource, YAMLS if (comment != null) return comment; String sep = String.valueOf(separator()); - + // If the comment is not found, try to get the comment from the parent section String[] keys = key.split(sep); if (keys.length == 1) return null;