From b911613abef8ba1cc62dbf5040d6b03844b6710b Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Mon, 27 Dec 2021 09:47:14 +1100 Subject: [PATCH] #701: Option to configure the max width of a line in the config By: Wolf2323 --- .../configuration/file/YamlConfiguration.java | 1 + .../file/YamlConfigurationOptions.java | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfiguration.java b/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfiguration.java index fc4460d94d..bfde43b293 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfiguration.java +++ b/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfiguration.java @@ -71,6 +71,7 @@ public class YamlConfiguration extends FileConfiguration { @Override public String saveToString() { yamlDumperOptions.setIndent(options().indent()); + yamlDumperOptions.setWidth(options().width()); yamlDumperOptions.setProcessComments(options().parseComments()); MappingNode node = toNodeTree(this); diff --git a/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfigurationOptions.java b/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfigurationOptions.java index d687389990..7d244fab46 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfigurationOptions.java +++ b/paper-api/src/main/java/org/bukkit/configuration/file/YamlConfigurationOptions.java @@ -11,6 +11,7 @@ import org.jetbrains.annotations.Nullable; */ public class YamlConfigurationOptions extends FileConfigurationOptions { private int indent = 2; + private int width = 80; protected YamlConfigurationOptions(@NotNull YamlConfiguration configuration) { super(configuration); @@ -100,4 +101,25 @@ public class YamlConfigurationOptions extends FileConfigurationOptions { this.indent = value; return this; } + + /** + * Gets how long a line can be, before it gets split. + * + * @return How the max line width + */ + public int width() { + return width; + } + + /** + * Sets how long a line can be, before it gets split. + * + * @param value New width + * @return This object, for chaining + */ + @NotNull + public YamlConfigurationOptions width(int value) { + this.width = value; + return this; + } }