From 039d73598a0eaeeb1ee59c15f61a12bce7c35ffc Mon Sep 17 00:00:00 2001 From: jascotty2 Date: Sun, 27 Oct 2019 15:52:52 -0500 Subject: [PATCH] handle comments with newlines as individual lines, add anonymous config --- .../java/com/songoda/core/configuration/Comment.java | 11 ++++------- .../java/com/songoda/core/configuration/Config.java | 7 +++++++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Core/src/main/java/com/songoda/core/configuration/Comment.java b/Core/src/main/java/com/songoda/core/configuration/Comment.java index bbc97482..206471b9 100644 --- a/Core/src/main/java/com/songoda/core/configuration/Comment.java +++ b/Core/src/main/java/com/songoda/core/configuration/Comment.java @@ -23,24 +23,21 @@ public class Comment { } public Comment(String... lines) { - this.lines.addAll(Arrays.asList(lines)); + this(null, Arrays.asList(lines)); } public Comment(List lines) { - if (lines != null) { - this.lines.addAll(lines); - } + this(null, lines); } public Comment(CommentStyle commentStyle, String... lines) { - this.commentStyle = commentStyle; - this.lines.addAll(Arrays.asList(lines)); + this(commentStyle, Arrays.asList(lines)); } public Comment(CommentStyle commentStyle, List lines) { this.commentStyle = commentStyle; if (lines != null) { - this.lines.addAll(lines); + lines.forEach(s -> this.lines.addAll(Arrays.asList(s.split("\n")))); } } diff --git a/Core/src/main/java/com/songoda/core/configuration/Config.java b/Core/src/main/java/com/songoda/core/configuration/Config.java index d7909b19..0cee70c2 100644 --- a/Core/src/main/java/com/songoda/core/configuration/Config.java +++ b/Core/src/main/java/com/songoda/core/configuration/Config.java @@ -109,6 +109,13 @@ public class Config extends ConfigSection { */ int commentSpacing = 1; + public Config() { + this.plugin = null; + this.file = null; + dirName = null; + fileName = null; + } + public Config(@NotNull File file) { this.plugin = null; this.file = file.getAbsoluteFile();