Certain questions with Deserialization

Discussion in 'Plugin Development' started by RcExtract, Jun 26, 2017.

Thread Status:
Not open for further replies.
  1. Offline


    I read tutorials about configuration Serialization and it teaches me to make a deserialize method. Is it necessary? When do I use the method? Is there an alternative method?

    Besides, what is the annotation @SerializableAs(Something) for? How to use it? Thanks.
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline


  4. Offline

    timtower Administrator Administrator Moderator

    Somewhere far away, I know that it is being called because my objects get loaded again.
    Should be somewhere in the get method.
  5. Offline


    You know when you save a Location to the config (which implements ConfigurationSerializable), then you see ===: Location. That is what the SerializableAs("Location") annotation is for. If you choose to not have it, then Bukkit will decide it (will pick your package path + object name). For example ===: org.bukkit.Location:
  6. Offline


    The deserialize method is not necessary, if you try to get an object which does not have a deserialize method from the config, it will return null. You could make your own method to deserialize, but it would basically be the same as the regular one that is called when you use Config#get(), except you would need to explicitly call it, and also you'd need to do something like this to get a hashmap:
Thread Status:
Not open for further replies.

Share This Page