#701: Option to configure the max width of a line in the config

By: Wolf2323 <gabrielpatrikurban@gmail.com>
This commit is contained in:
Bukkit/Spigot 2021-12-27 09:47:14 +11:00
parent a4c6cce830
commit b911613abe
2 changed files with 23 additions and 0 deletions

View File

@ -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);

View File

@ -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;
}
}