Solved Config not setting Value.

Discussion in 'Spigot Plugin Development' started by izibane, May 1, 2017.

  1. Fixed: Access the data file in a static way.
    #1 izibane, May 1, 2017
    Last edited: May 5, 2017
  2. Maybe it crashes when you try to save the config. Check out the logs!
  3. That is most likely the issue. Where is the code that initiates the variable "d"? There might be an issue there. Make sure to stick to Java naming conventions if you plan to share snippets of code.
    • Agree Agree x 1
  4. I think that the rest of the code is fine since it saves his data.yml. It seems that the error is when he tries to save the configuration with the new boolean value.
  5. It does not crash, the plugin doesn't crash. There is no error in logs,
    d is File d = new File(Main.getCore().getDataFolder(), "data.yml");
  6. My API is Java/Bukkit :p
  7. Yeah but it's an API.. It just increases file size (I know it provides stuff). I'll only make my own classes.
  8. Then Learn Java :p
  9. This is not a nice excuse to not use his API.
    • Agree Agree x 1
  10. As long as it doesn't require the user to install another plugin, I don't see what's wrong. We live in a day where a few extra kb is considered near to nothing.
  11. He knows Java, he's asking for help because the Bukkit API won't do what he wants.
    Are you asserting that 96 kilobytes is not a lot?
    I think instead of asking this user to use an API, attempt to teach this person how to do what he wants to learn how to do, this is something that's supposed to be working, but it's not.
    • Agree Agree x 1
  12. Let's get back to the actual question how about that?

    I have made sure that the Boolean it's changing is not a null value or that it's changing the Boolean in the right path.

    If you want I can upload the source code.
  13. Do so, right now we cannot see anything wrong. By the way, you shouldn't load the config every time that method is called for performance sake. It's better to store it and save the config once you are done.
  14. Agreed. Fatal, I suggest making a util class that contains one instance of your files/config, and has specific methods that you need, such as this one. Then access them by creating a singleton instance of the class. This may help, and even fix your problem if it's a performance thing.
  15. This is because for the Violations in the Message to update, unfortunately, it doesn't update without it.

    I don't really want to make a class if it's going to be used once. But fine I'll try.