Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
YamlRepresenter.java
1 package org.bukkit.configuration.file;
2 
3 import java.util.LinkedHashMap;
4 import java.util.Map;
5 
9 
10 import org.yaml.snakeyaml.nodes.Node;
11 import org.yaml.snakeyaml.representer.Representer;
12 
13 public class YamlRepresenter extends Representer {
14 
15  public YamlRepresenter() {
16  this.multiRepresenters.put(ConfigurationSection.class, new RepresentConfigurationSection());
17  this.multiRepresenters.put(ConfigurationSerializable.class, new RepresentConfigurationSerializable());
18  }
19 
20  private class RepresentConfigurationSection extends RepresentMap {
21  @Override
22  public Node representData(Object data) {
23  return super.representData(((ConfigurationSection) data).getValues(false));
24  }
25  }
26 
27  private class RepresentConfigurationSerializable extends RepresentMap {
28  @Override
29  public Node representData(Object data) {
31  Map<String, Object> values = new LinkedHashMap<String, Object>();
32  values.put(ConfigurationSerialization.SERIALIZED_TYPE_KEY, ConfigurationSerialization.getAlias(serializable.getClass()));
33  values.putAll(serializable.serialize());
34 
35  return super.representData(values);
36  }
37  }
38 }
static String getAlias(Class<?extends ConfigurationSerializable > clazz)