Solved Saving an ArrayList<Location> in Yaml

Discussion in 'Plugin Development' started by MOMOTHEREAL, Jan 31, 2014.

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

    MOMOTHEREAL

    Hello there,
    I am working on a FFA plugin for a friend.
    So, I have a spawnLocations ArrayList<Location> thats stores all the spawn locations.
    Now, I want to save the list in the config file in the onDisable and to load it in the onEnable as the "data.spawns" path. I tried to put this in the onDisable():
    Code:
    this.getConfig().set("data.spawns", PlayerManager.spawnLocations);
    this.saveConfig();
    But I get an error which tells that the Location type is not compatible with Yaml.

    How could I save it and so could be compatible with loading it too?

    ~Momo
     
  2. I would strongly recommend actually saving the x,y,z,world instead of an actual location.
     
    Nateb1121 likes this.
  3. Offline

    Nateb1121

    MOMOTHEREAL

    Yes, Barking_Squirrel has the right idea. You can't save an instance of location, you're better off storing the coordinates (which should include the world to be safe).
     
    Barking_Squirrel likes this.
  4. Offline

    MOMOTHEREAL

  5. Offline

    The_Doctor_123

    Load and deserialize.
     
    MOMOTHEREAL likes this.
  6. Offline

    ItsOneAndTwo

  7. Offline

    MOMOTHEREAL

  8. Offline

    ItsOneAndTwo

    MOMOTHEREAL likes this.
Thread Status:
Not open for further replies.

Share This Page