Saving data to a YAML configuration

Now, we are ready to complete the save method. We want to save data to a YAML file, much like how we did in config.yml. However, we do not want to save it to config.yml, because that serves a different purpose. The first thing that we will need to do is create a new YAML configuration, as follows:

YamlConfiguration config = new YamlConfiguration();

Next, we will store all the information that we wish to save. This is done by setting objects to specific paths, as follows:

config.set(String path, Object value);

The acceptable types for value were mentioned earlier in this chapter. In the teleportation plugin, we have maps, which contain the SerializableLocation method. Maps can be added to a YAML configuration as ...

Get Building Minecraft Server Modifications - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.