Multi string field in config

Discussion in 'Plugin Development' started by RiseOfDeath, Jan 22, 2012.

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


    I have this (for example) YAML config. How i can load "Text" field as List, or Vector or Array or just String (with '\n' symbols)?
    If a load this as String (cfg.getString("Text")) it's return null;
      Title: Mary
      Tags: [Mary, Triva]
      Permission: mccityhelp.user
    Text: |
      Mary had a little lamb ,
      Its fleece was white as snow;
      And everywhere that Mary went,
      The lamb was sure to go. He followed her to school one day;
      Which was against the rule;
      It made the children laugh and play;
      The eager children cry;
      "Why, Mary loves the lamb, you know,"
      The teacher did reply.
  2. Offline


    I think you must place your text in one line if you're using a YAML configuration.
    However,you can use splits.
    For ex. you can split the ";" keyword to split up lines.
    So if the user set the text in the config to: Hello ;World
    Then you can use String[] lines = getConfig().getString("text").split(";");
    Or something like this,i done this from hearth and i didn't used splits before.
    However i'm pretty sure now you can figure out how to use splitting :)
  3. Offline

    Sagacious_Zed Bukkit Docs

    It's very possible that the parser does not parse multiline strings correctly. I don't see a test testing it specifically. But at this time I can not independently confirm or deny that there is a bug in the parser.
    Ill be back with more tests!
  4. Offline


    In the chat it will look disgusting.

    I try to use Splits...

    I invented another solution:

    And i failed again.

    List<String> listBuf=new ArrayList<String>();
    listBuf.add(" bla-bla-bla ");
    listBuf.add(" bla-bla-bla ");
    try {;
    } catch (IOException e) {
    // TODO Auto-generated catch block

    this code save it as
      Title: somthing
      Tags: somthing
      Permissions: somthing
    - bla-bla-bla
    - bla-bla-bla
    - bla-bla-bla
    but it can't read it
    cfg.isList("Text") return false
    cfg.getList("Text") and cfg.getStringList("Text") return null


    cfg.get("Text") return null too

    Ha-ha, now i can't get String, which saved as string 0_0

    and does not want to load only the "Text"

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 23, 2016
Thread Status:
Not open for further replies.

Share This Page