mirror of
https://github.com/TotalFreedomMC/PlayerParticles.git
synced 2025-07-23 05:54:01 +00:00
Updated config comment handling to support 1.18.1 properly
This commit is contained in:
parent
c60d90b261
commit
1c0dd516e2
3 changed files with 34 additions and 2 deletions
|
@ -35,7 +35,7 @@ dependencies {
|
|||
compileOnly 'org.jetbrains:annotations:16.0.2'
|
||||
compileOnly 'me.clip:placeholderapi:2.10.4'
|
||||
compileOnly 'org.xerial:sqlite-jdbc:3.23.1'
|
||||
compileOnly 'org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT'
|
||||
compileOnly 'org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT'
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
|
|
|
@ -393,4 +393,24 @@ public class CommentedConfigurationSection implements ConfigurationSection {
|
|||
this.config.addDefault(s, o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getComments(String path) {
|
||||
throw new IllegalStateException("CommentedConfigurationSection does not support Spigot-API comment methods.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getInlineComments(String path) {
|
||||
throw new IllegalStateException("CommentedConfigurationSection does not support Spigot-API comment methods.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setComments(String path, List<String> comments) {
|
||||
throw new IllegalStateException("CommentedConfigurationSection does not support Spigot-API comment methods.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInlineComments(String path, List<String> comments) {
|
||||
throw new IllegalStateException("CommentedConfigurationSection does not support Spigot-API comment methods.");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -76,13 +76,25 @@ public class CommentedFileConfiguration extends CommentedConfigurationSection {
|
|||
|
||||
// Edit the configuration to how we want it
|
||||
try {
|
||||
Field field_yamlOptions = YamlConfiguration.class.getDeclaredField("yamlOptions");
|
||||
Field field_yamlOptions;
|
||||
try {
|
||||
field_yamlOptions = YamlConfiguration.class.getDeclaredField("yamlOptions");
|
||||
} catch (NoSuchFieldException e) { // This is used for 1.18.1+
|
||||
field_yamlOptions = YamlConfiguration.class.getDeclaredField("yamlDumperOptions");
|
||||
}
|
||||
|
||||
field_yamlOptions.setAccessible(true);
|
||||
DumperOptions yamlOptions = (DumperOptions) field_yamlOptions.get(yamlConfiguration);
|
||||
yamlOptions.setWidth(Integer.MAX_VALUE);
|
||||
|
||||
if (Stream.of(DumperOptions.class.getDeclaredMethods()).anyMatch(x -> x.getName().equals("setIndicatorIndent")))
|
||||
yamlOptions.setIndicatorIndent(2);
|
||||
|
||||
if (Stream.of(DumperOptions.class.getDeclaredMethods()).anyMatch(x -> x.getName().equals("setProcessComments")))
|
||||
yamlOptions.setProcessComments(false);
|
||||
|
||||
if (Stream.of(DumperOptions.class.getDeclaredMethods()).anyMatch(x -> x.getName().equals("setSplitLines")))
|
||||
yamlOptions.setSplitLines(false);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue