Configuration always return nulls

Discussion in 'Plugin Development' started by xZise, Mar 24, 2011.

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

    xZise

    Hello,
    maybe I misused the Configuration class, but I'm only getting nulls:

    Code:
    public void loadSettings(File dataPath) {
            System.out.println("FILE: " + new File(dataPath, "qukkiz.yml"));
            Configuration config = new Configuration(new File(dataPath, "qukkiz.yml"));
            ConfigurationNode rewardsNode = config.getNode("rewards");
    
            System.out.println("rewards: " + rewardsNode);
            this.pointsReward = RewardSettings.create(new PointsRewardSettings(), rewardsNode);
            this.itemsReward = RewardSettings.create(new ItemsRewardSettings(), rewardsNode);
            this.coinsReward = RewardSettings.create(new CoinsRewardSettings(), rewardsNode);
            this.questionfiles = convert(config.getStringList("questions.files", new ArrayList<String>(0)), dataPath);
            this.questionsDelay = config.getInt("questions.delay", 5);
            ConfigurationNode hintsNode = config.getNode("questions.hints");
            System.out.println("questions.hints: " + hintsNode);
            if (hintsNode != null) {
                this.hintCount = hintsNode.getInt("count", 3);
                this.hintDelay = hintsNode.getInt("delay", 15);
            } else {
                this.hintCount = 3;
                this.hintDelay = 15;
            }
            this.intHinter = HinterSettings.create(new IntHinterSettings(), hintsNode);
            this.wordHinter = HinterSettings.create(new WordHinterSettings(), hintsNode);
            this.choiceHinter = HinterSettings.create(new ChoiceHinterSettings(), hintsNode);
            System.out.println("ranking.database: " + config.getString("ranking.database"));
            this.database = new File(dataPath, config.getString("ranking.database", "qukkiz.db"));
        }
    Now I got this in my console:
    Code:
    13:32:22 [INFO] FILE: plugins/Qukkiz/qukkiz.yml
    13:32:22 [INFO] rewards: null
    13:32:22 [INFO] questions.hints: null
    13:32:22 [INFO] ranking.database: null
    And this is my qukkiz.yml file:
    Code:
    xzise@fabian-m:~/Programme/Minecraft/RB$ cat plugins/Qukkiz/qukkiz.yml
    rewards:
      points:
        start: 10
        decrease: 2
      items:
        list: [87, 88, 89, 12, 21]
      coins:
        start: 10
        decrease: 3
    questions:
      files:
        - 'questions/german.txt'
        - 'questions/scramble.txt'
      hints:
        count: 3
        delay: 15
        word:
          letters-per-hint: 8
        int:
          start: 200
          decrease: 4
      delay: 5
    ranking:
      database: 'trivia.db'
    Now what did I wrong?

    Fabian

    Thank you alot for your help. I missed to load the file. So if anyone have similar problems add following line after the constructor.
    Code:
    config.load()
    Fabian

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

Share This Page