Skip to content

Commit

Permalink
Fix default config options not working
Browse files Browse the repository at this point in the history
Signed-off-by: DevDrizzy <[email protected]>
  • Loading branch information
DevDrizzy committed Oct 14, 2023
1 parent bf19b96 commit f3596b3
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/main/java/xyz/refinedev/api/storage/YamlStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ public YamlStorage(JavaPlugin plugin, String name, boolean saveResource) {
this.name = name;
this.config = new YamlFile(file);

// Default options of this Yaml Storage
// User can set their own by overriding this method
this.setupConfigOptions(this.config.options());

if (!file.exists()) {
try {
if (saveResource) {
Expand Down Expand Up @@ -116,7 +112,6 @@ public void readConfig() {
// between different keys, making config look awful
if (configValue.comment().length() > 0) {
this.config.path(configValue.path()).comment(configValue.comment()).blankLine();
//this.config.setComment(configValue.path(), "\n#" + configValue.comment(), YamlCommentFormat.DEFAULT);
}

} catch (IllegalArgumentException | IllegalAccessException ex) {
Expand All @@ -125,6 +120,11 @@ public void readConfig() {
}

this.addSeparateComments();

// Default options of this Yaml Storage
// User can set their own by overriding this method
this.setupConfigOptions(this.config.options());

this.saveConfig();
}

Expand Down Expand Up @@ -189,6 +189,7 @@ public void setupConfigOptions(YamlConfigurationOptions options) {
options.charset(Charsets.UTF_8);
options.useComments(true);
options.quoteStyleDefaults().setQuoteStyle(String.class, QuoteStyle.DOUBLE);
options.quoteStyleDefaults().setQuoteStyle(List.class, QuoteStyle.DOUBLE);
options.header(String.join("\n", this.getHeader()));
}

Expand Down Expand Up @@ -256,6 +257,10 @@ public void addComment(String path, String comment) {
this.config.setComment(path, comment);
}

public void addCommentWithBlankLine(String path, String comment) {
this.config.path(path).comment(comment).blankLine();
}

public Object get(String path) {
return this.config.contains(path) ? this.config.get(path) : null;
}
Expand Down

0 comments on commit f3596b3

Please sign in to comment.