Skip to content

Commit 7f11bc9

Browse files
committed
Fixed inline comments
1 parent adf42d2 commit 7f11bc9

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

README.MD

100644100755
+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ maven {
2121
url = 'https://repo.mikigal.pl/releases'
2222
}
2323
24-
compile group: 'pl.mikigal', name: 'ConfigAPI', version: '1.2.4'
24+
compile group: 'pl.mikigal', name: 'ConfigAPI', version: '1.2.5'
2525
```
2626

2727
#### Maven
@@ -34,7 +34,7 @@ compile group: 'pl.mikigal', name: 'ConfigAPI', version: '1.2.4'
3434
<dependency>
3535
<groupId>pl.mikigal</groupId>
3636
<artifactId>ConfigAPI</artifactId>
37-
<version>1.2.4</version>
37+
<version>1.2.5</version>
3838
<scope>compile</scope>
3939
</dependency>
4040
```

build.gradle

100644100755
+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
}
55

66
group 'pl.mikigal'
7-
version '1.2.4'
7+
version '1.2.5'
88

99
publishing {
1010
repositories {

src/main/java/pl/mikigal/config/BukkitConfiguration.java

100644100755
+17-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
import org.bukkit.configuration.InvalidConfigurationException;
44
import org.bukkit.configuration.file.YamlConfiguration;
5-
import org.bukkit.configuration.file.YamlRepresenter;
65
import org.yaml.snakeyaml.DumperOptions;
7-
import org.yaml.snakeyaml.Yaml;
86
import pl.mikigal.config.annotation.Comment;
97
import pl.mikigal.config.exception.InvalidConfigException;
108
import pl.mikigal.config.exception.MissingSerializerException;
@@ -112,6 +110,8 @@ public Object get(String path) {
112110
*/
113111
@Override
114112
public String saveToString() {
113+
this.overrideMaxLineWidth();
114+
115115
String yaml = super.saveToString();
116116

117117
List<String> lines = new ArrayList<>();
@@ -208,6 +208,21 @@ private void copyDefaultConfig() {
208208
}
209209
}
210210

211+
/**
212+
* Set SnakeYaml's max line width to max Integer value.
213+
* Required for inline comments
214+
*/
215+
private void overrideMaxLineWidth() {
216+
try {
217+
Field yamlOptionsField = YamlConfiguration.class.getDeclaredField("yamlOptions");
218+
yamlOptionsField.setAccessible(true);
219+
DumperOptions yamlOptions = (DumperOptions) yamlOptionsField.get(this);
220+
yamlOptions.setWidth(Integer.MAX_VALUE);
221+
} catch (Exception e) {
222+
throw new RuntimeException("Could not set max YAML line width", e);
223+
}
224+
}
225+
211226
/**
212227
* Add value to cache for optimization, to do not parse it every time user want to access it
213228
* @param path path in config

0 commit comments

Comments
 (0)