(Config) Need help!

Discussion in 'Plugin Development' started by Gabum, May 17, 2014.

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

    Gabum

    Hello!
    I'm currently working at a custom dialogues Plugin, and I want to work with the config.yml to save them. But I always get a NullPointerException at this line:
    Code:java
    1. int max = fc.getList("dialogues." + s.getLine(2) + ".lines").size();


    Here is the whole code:

    Code:java
    1. FileConfiguration fc = Bukkit.getPluginManager().getPlugin("KnightsOfCosmica").getConfig();
    2.  
    3. int i = 0;
    4. int max = fc.getList("dialogues." + s.getLine(2) + ".lines").size();
    5. List<String> lines = (List<String>) fc.getList("dialogues." + s.getLine(2) + "lines");


    s is a sign, and with s.getLine(2) the third line of the sign is gotten.

    So, how can I fix this?
     
  2. Offline

    Minesuchtiiii

    I would use FileConfiguration fc = this.getConfig();
     
  3. Offline

    Rocoty

    Gabum Can you verify that fc isn't null? Also if you are working with strings, you would be better off using getStringList
     
  4. Offline

    hugokk

    Also check first if your Sign object isn't null
     
  5. Offline

    Gabum

    Thx for all the answers, I had personal problems so I did not answer(exams etc), and I now got some work on the problem.

    I fixed the first mistake, the path in the config.yml was just in wrong order. But now, if I try to get the list, there is just no object in it. Could you guys tell me the syntax for a String List in the config.yml?

    Nevermind, guys. I just found it out:

    PHP:
    dialogues:
      
    Chests:
        
    lines:
        - 
    Dialogue Line 1
        
    Dialogue Line 2
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
Thread Status:
Not open for further replies.

Share This Page