|
1 | 1 | package pl.mikigal.config; |
2 | 2 |
|
| 3 | +import org.bukkit.Bukkit; |
3 | 4 | import org.bukkit.configuration.InvalidConfigurationException; |
4 | 5 | import org.bukkit.configuration.file.YamlConfiguration; |
5 | 6 | import org.yaml.snakeyaml.DumperOptions; |
|
11 | 12 | import pl.mikigal.config.style.CommentStyle; |
12 | 13 | import pl.mikigal.config.style.NameStyle; |
13 | 14 | import pl.mikigal.config.util.ConversionUtils; |
| 15 | +import pl.mikigal.config.util.ReflectionUtils; |
14 | 16 | import pl.mikigal.config.util.TypeUtils; |
15 | 17 |
|
16 | 18 | import java.io.*; |
@@ -41,6 +43,12 @@ public class BukkitConfiguration extends YamlConfiguration { |
41 | 43 | private final Map<String, Object> cache; |
42 | 44 | private final Map<String, String> comments; |
43 | 45 |
|
| 46 | + /** |
| 47 | + * |
| 48 | + * Reflection Path |
| 49 | + */ |
| 50 | + private final String dumperFieldName = ReflectionUtils.isVeryNewVersion() ? "yamlDumperOptions" : "yamlOptions"; |
| 51 | + |
44 | 52 | public BukkitConfiguration(File directory, File file, NameStyle nameStyle, CommentStyle commentStyle, |
45 | 53 | boolean automaticColorStrings, String configComment) { |
46 | 54 | this.directory = directory; |
@@ -214,7 +222,7 @@ private void copyDefaultConfig() { |
214 | 222 | */ |
215 | 223 | private void overrideMaxLineWidth() { |
216 | 224 | try { |
217 | | - Field yamlOptionsField = YamlConfiguration.class.getDeclaredField("yamlOptions"); |
| 225 | + Field yamlOptionsField = YamlConfiguration.class.getDeclaredField(dumperFieldName); |
218 | 226 | yamlOptionsField.setAccessible(true); |
219 | 227 | DumperOptions yamlOptions = (DumperOptions) yamlOptionsField.get(this); |
220 | 228 | yamlOptions.setWidth(Integer.MAX_VALUE); |
|
0 commit comments