If you recall from the previous chapter, only certain data types can be stored in a YAML file. These include primitive types (such as int
or boolean
), strings, lists, and types that implement ConfigurationSerializable
(such as ItemStack
). For this reason, we are only able to store these specific types of data.
You may find yourself wanting to save other types of data such as a Player
object, or in the case of our teleportation plugin, a
Location
object. These may not be stored directly, but can usually be broken down in order to save the important values that are needed to load it later. As an example, you cannot save a Player
object, but you can save the player's name which is a string. Their name is unique, so it is the only information we need to be able to refer to that specific player later. Similarly, a Location
object can be broken down to its world, x, y, and z coordinates, yaw, and pitch. All of these but the world are simply numbers which can be...