2016-10-02 17:12:20 +00:00
|
|
|
package pw.yumc.YumCore.config.yaml;
|
|
|
|
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.configuration.file.YamlRepresenter;
|
|
|
|
import org.yaml.snakeyaml.nodes.Node;
|
2016-11-04 02:15:42 +00:00
|
|
|
import org.yaml.snakeyaml.representer.Represent;
|
2016-10-02 17:12:20 +00:00
|
|
|
import pw.yumc.YumCore.bukkit.L;
|
|
|
|
|
|
|
|
public class BukkitRepresenter extends YamlRepresenter {
|
2016-11-04 02:15:42 +00:00
|
|
|
public static BukkitRepresenter DEFAULT = new BukkitRepresenter();
|
|
|
|
|
2016-10-02 17:12:20 +00:00
|
|
|
public BukkitRepresenter() {
|
|
|
|
this.multiRepresenters.put(Location.class, new RepresentLocation());
|
|
|
|
}
|
|
|
|
|
2016-11-04 02:15:42 +00:00
|
|
|
public static void register(Class<?> clazz, Represent represent) {
|
|
|
|
DEFAULT.multiRepresenters.put(clazz, represent);
|
|
|
|
}
|
|
|
|
|
2016-10-02 17:12:20 +00:00
|
|
|
public class RepresentLocation extends RepresentMap {
|
|
|
|
@Override
|
2016-10-11 17:14:57 +00:00
|
|
|
public Node representData(Object data) {
|
2016-10-02 17:12:20 +00:00
|
|
|
return super.representData(L.serialize((Location) data));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|