Solved Setting configuration section acts weird

Discussion in 'Plugin Development' started by Brixishuge, Apr 5, 2014.

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

    Brixishuge

    Hello, I'm trying to change an integer in given config section but can't get it to work.

    So command is like:

    /command give Playername amount

    Code:

    Code:
    math = int(points) + int(amount)
    section.set("target.points", math)
    section = pyplugin.getCfg().getConfigurationSection("main")
    Config:

    Code:
    main:
      Brixishuge:
        points: 5
    P.S. I'm coding in Python, so it may be weird for you, anyway, problem is in setting section points...

    P.P.S Math is okay, when I print it out, it gives correct answer, so it's problem in setting "section.set("target.points", math)" this part...

    Thanks in advance!
     
  2. Offline

    St3venAU

    Are you saving the configuration after you set the value? If you don't, it wont save the changes to file.
     
  3. Offline

    Brixishuge

    St3venAU Haven't been doing with configs for a while, I forgot that. How do I save it actually, ik I can google it but I'm in a hurry little bit.
     
  4. Offline

    St3venAU

    plugin.saveConfig();
     
  5. Offline

    Brixishuge

    St3venAU

    nah, not working again :/ no errors, it's not chaning in cfg..
     
  6. Offline

    St3venAU

    I cant help you with the python, but in java I would have:
    Code:java
    1. plugin.getConfig().set("main."+player.getName()+".points",math);
    2. plugin.saveConfig();
     
  7. Offline

    Brixishuge

    St3venAU

    It looks like Python has problems with saveConfig() function, so I used this:

    Code:
                  all = "%s.points"%target1
                  section.set(all, math)
                  pluginlokacija1 = os.path.realpath("%s/plugins"%os.getcwd())
                  pyplugin.getCfg().save(File(os.path.join("%s/CreativePoints/"%pluginlokacija1,"config.yml")))
                  pyplugin.onEnable()
    Thank you anyway.
     
Thread Status:
Not open for further replies.

Share This Page