Solved How to deserialize an object that contains deserializable variables

Discussion in 'Spigot Plugin Development' started by _xXProDudeXx_, Feb 10, 2020.

  1. Hey guys,

    I have a custom object that has the 'ConfigurationSerializable' interface implemented. Now it works perfectly fine with serializing but the problem comes when I try to deserialize, here's my issue:
    Also take a look at the comments I made, it explains the rest a bit more in detail :)

    Thanks in advance!

    Code (Java):
    public final class MyCustomObject implements ConfigurationSerializable {
        private final UUID id;
        private final Location location; // just a ConfigurationSerializable object...

        public MyCustomObject(Location location) {
   = UUID.randomUUID();
            this.location = location;

        public Location getLocation() {
            return location;

        public UUID getId() {
            return id;

        public Map<String, Object> serialize() {
            return new HashMap<>(); // no need to work this out, it works fine.
        public static MyCustomObject deserialize(Map<String, Object> map){
            UUID id = UUID.fromString((String) map.get("id"));
            // how do I fetch a location here, since the location is stored as a
            // serializable to my configuration file. I also can't access the configuration
            // file from this method and there is no way I could possibly think of to make
            // that happen, so how do I solve this? :-)
            return null; // just so that my IDE doesn't give me errors ;-)
    EDIT 1:
    I just realized that I am storing a HashMap inside a HashMap in my particular object and that it could be possible to use the Map#get() method and cast a Map to the result and use this to get my result, this post might be unnecassary and I'll close it as soon as possible once I found the solution :). Any further replies are very welcome!

    EDIT 2:
    Decided to read the Javadoc for the second time and saw that I forgot to register my ConfigurationSerializable class. After doing so my error was gone :)
    #1 _xXProDudeXx_, Feb 10, 2020
    Last edited: Feb 10, 2020