Save object in list YAML

Discussion in 'Plugin Development' started by Nogtail, Jun 7, 2014.

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

    Nogtail

    So for example if I have an object that has field1, field2 and field3 and I wanted to save it in the config like:
    Code:
    objects:
      - field1: "The value of field1 in object1"
        field2: "The value of field2 in object1"
        field3: "The value of field3 in object1"
      - field1: "The value of field1 in object2"
        field2: "The value of field2 in object2"
        field3: "The value of field3 in object2"
    How would I be able to do this with the config API?
     
  2. Offline

    TheWolfBadger

    getConfig().set("object1.field1", Object);
    getConfig().set("object1.field2", Object);
    and so forth. Then if you want object2 to have things:
    getConfig.set("object2.field1", Object);
    getConfig.set("object2.field2", Object);
    and so forth also.
    EDIT: Nogtail
     
  3. Offline

    Code0

  4. Offline

    TheWolfBadger

    Code0 I didn't quite get what he wanted to achieve! :p
     
  5. Offline

    Code0

    TheWolfBadger I think he meant StringLists and then set values :). But close enough ;).
     
    TheWolfBadger likes this.
  6. Offline

    Nogtail

    TheWolfBadger Wouldn't that make something more like:
    Code:
    objects:
      object1:
        field1: {serialized object}
        field2: {serialized object}
      object2:
        field1: {serialized object}
        field2: {serialized object}
     
  7. Offline

    TheWolfBadger

  8. Offline

    Nogtail

    TheWolfBadger Would you know how to or if it is possible to do it in a list? as the objects do not have any order or individually defining values associated with them.
     
  9. Offline

    TheWolfBadger

    Nogtail
    getConfig().set("object1", definedHashMap);
    saveConfig();
    EDIT: Fixed. LOL
     
Thread Status:
Not open for further replies.

Share This Page