New configurations help...

Discussion in 'Plugin Development' started by stelar7, Oct 12, 2011.

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


    so I want to change my plugin to use the new configurations, but it does not work how i want it...

    here is the code:
    1. public class ClosedDoors extends JavaPlugin {
    2. FileConfiguration config;
    4. public void onEnable() {
    5. try {
    6. config = getConfig();
    7. config.options().header("Change the values to suit you best");
    8. config.get("storm.radius", 20);
    9. config.get("storm.repeat", 20);
    10. config.get("", true);
    11. config.get("", true);
    12. config.get("", true);
    13. saveConfig();
    14. } catch (Exception e1) {
    15. e1.printStackTrace();
    16. }
    17. }
    18. }
    this code creates a file like this:
    # Change the values to suit you best
    how do i get the rest of it?
  2. Offline


        config.set("storm.radius", 20);
    and then if you need it config.getint("storm.radius")
  3. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    I think he means "How do I do this in a way that doesn't require a billion if() statements." :p
  4. Offline


    Yeah :p
    With the old you just used config.getint("storm.radius", 20); and there it was...
    maybe @Dinnerbone knows how?
    But it's fine if there is just a few like i had :p
  5. Offline

    Sagacious_Zed Bukkit Docs

    You mean like providing default values?
  6. Offline


    yeah i dont know why this does not work anymore, cause you can still provide default
    it is just not written to the config -_-

    and btw - i just recognised the adddefault(....) and options().copydefaults(true)
    perhaps it works with copydefaults true ?
  7. Offline


    Just tried and if you do config.options().copyDefaults(true); and use addDefault(whatever the arguments are); and then saveConfig(); it will work and only will set if its not there.
  8. Offline


    I figured it out kinda I just do this and it prints it out onto the config in thos order for once.
        public void configSetup() {
        try {
            config = getConfig();
            config.set("String here", " default here ");
            config.set("String here ", " default here");
         catch (Exception ex) {
Thread Status:
Not open for further replies.

Share This Page