mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-14 11:45:52 -07:00
@@ -56,16 +56,16 @@ public class YamlConfiguration extends FileConfiguration {
|
||||
private final Yaml yaml;
|
||||
|
||||
public YamlConfiguration() {
|
||||
constructor = new YamlConstructor();
|
||||
representer = new YamlRepresenter();
|
||||
representer.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
|
||||
yamlDumperOptions = new DumperOptions();
|
||||
yamlDumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
yamlLoaderOptions = new LoaderOptions();
|
||||
yamlLoaderOptions.setMaxAliasesForCollections(Integer.MAX_VALUE); // SPIGOT-5881: Not ideal, but was default pre SnakeYAML 1.26
|
||||
yamlLoaderOptions.setCodePointLimit(Integer.MAX_VALUE); // SPIGOT-7161: Not ideal, but was default pre SnakeYAML 1.32
|
||||
|
||||
constructor = new YamlConstructor(yamlLoaderOptions);
|
||||
representer = new YamlRepresenter(yamlDumperOptions);
|
||||
representer.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
|
||||
yaml = new Yaml(constructor, representer, yamlDumperOptions, yamlLoaderOptions);
|
||||
}
|
||||
|
||||
|
@@ -5,6 +5,7 @@ import java.util.Map;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.yaml.snakeyaml.LoaderOptions;
|
||||
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||
import org.yaml.snakeyaml.error.YAMLException;
|
||||
import org.yaml.snakeyaml.nodes.MappingNode;
|
||||
@@ -13,7 +14,16 @@ import org.yaml.snakeyaml.nodes.Tag;
|
||||
|
||||
public class YamlConstructor extends SafeConstructor {
|
||||
|
||||
/**
|
||||
* @deprecated options required
|
||||
*/
|
||||
@Deprecated
|
||||
public YamlConstructor() {
|
||||
this(new LoaderOptions());
|
||||
}
|
||||
|
||||
public YamlConstructor(@NotNull LoaderOptions loaderOptions) {
|
||||
super(loaderOptions);
|
||||
this.yamlConstructors.put(Tag.MAP, new ConstructCustomObject());
|
||||
}
|
||||
|
||||
|
@@ -6,12 +6,22 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.nodes.Node;
|
||||
import org.yaml.snakeyaml.representer.Representer;
|
||||
|
||||
public class YamlRepresenter extends Representer {
|
||||
|
||||
/**
|
||||
* @deprecated options required
|
||||
*/
|
||||
@Deprecated
|
||||
public YamlRepresenter() {
|
||||
this(new DumperOptions());
|
||||
}
|
||||
|
||||
public YamlRepresenter(@NotNull DumperOptions options) {
|
||||
super(options);
|
||||
this.multiRepresenters.put(ConfigurationSection.class, new RepresentConfigurationSection());
|
||||
this.multiRepresenters.put(ConfigurationSerializable.class, new RepresentConfigurationSerializable());
|
||||
// SPIGOT-6234: We could just switch YamlConstructor to extend Constructor rather than SafeConstructor, however there is a very small risk of issues with plugins treating config as untrusted input
|
||||
|
Reference in New Issue
Block a user