[YAML] Problem with removing stuff from config.

Discussion in 'Plugin Development' started by McMhz, Jul 21, 2014.

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

    McMhz

    So yeah, I've been putting 'reports' in the default config file,
    And I want a player or console to be able to remove a report via command, this is where I need help.

    I know how to do the command itself, But I need help with removing a certain node and all the child 'items'.
    Setting everything to null, saving and reloading the config does not seem to work, any help is appreciated.

    Also, you don't need to see any code really, since its the same with basically everything, I just need to remove something from the config.

    By the way, I'm using this to remove the stuff atm
    Code:java
    1. getConfig().set("x", null); <-- I do this for every single value
    2. saveConfig();


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  2. Offline

    negative_codezZ

    Try saveDefaultConfig();. I have found it more reliable.
     
  3. Offline

    EcMiner

    Doesn't saveDefaultConfig() copy the config.yml file from the .jar file into the plugin's folder, so wouldn't that reset everything to default? Correct me if I'm wrong :)
     
    McMhz likes this.
  4. EcMiner negative_codezZ saveDefaultConfig() would only ever do anything if the config file doesn't currently exist, so it wouldn't reset anything.

    McMhz Remind me how it turns out when you set it all to null?
     
  5. Offline

    fireblast709

    McMhz likes this.
  6. fireblast709 Exactly, but it "doesn't work". Just waiting on his clarification on what actually happens :p
     
  7. Offline

    McMhz

    Okay, so I'll show you how I do it, And what happens is just, nothing.

    I make everything in the current 'report' to null, I do saveConfig() and reloadConfig()
    and it doesnt change at all.
     
  8. Offline

    fireblast709

    McMhz code and config please?
     
  9. Offline

    McMhz

    Well then, I was just really really sleepy last night and I forgot to put a dot in one of the places .-.
    Thanks anyway, I'm sorry if I wasted your time.
     
Thread Status:
Not open for further replies.

Share This Page