config.getString() always returns null???

Discussion in 'Plugin Development' started by main(), Sep 17, 2011.

Thread Status:
Not open for further replies.
  1. I'm writing a new plugin called "WolfPay" and I want to store the messages in the config so that the server-admin can change them. My problem is that config.getString(String path) always returns null. So calling config.getString(String path, String def) overwrites the values.
    https://gist.github.com/1224228
    Here you can see some debug-notifications and the code.
    (Notice: "havenow" is "fail" instead of null because I'm reading it with a default value in line 28)

    The entire source: https://github.com/main--/WolfPay
    Try it yourself: http://ci.maincraft.tk/job/WolfPay/
     
  2. You'll need to do config.load() first.
     
  3. Make sure you are loading the config and that the file you're loading from exists.
     
  4. Facepalm. Thanks.
     
  5. Don't use that fancy code including directories and files for your default config.yml.
    You can simply call getConfiguration() in your main class that gives you a ready-to-use Configuration at plugins/<pluginname>/config.yml.
    You don't need to .load() it or check if it exists, it also will be auto-created.
     
    main() likes this.
Thread Status:
Not open for further replies.

Share This Page