Remove a path from config?

Discussion in 'Plugin Development' started by BetaNyan, Oct 25, 2014.

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

    BetaNyan

    I am using a custom configuration manager, and I was wondering how I can remove a path from the config. The basic getConfig() in JavaPlugin doesn't have a remove method, and setting a path to null doesn't remove it either.

    Any way I can remove stuff? Thanks!
     
  2. Offline

    RingOfStorms

    Setting it to null and then saving will indeed remove it when using the YamlConfigurations. Since you say you;re using a custom manager we can't really troubleshoot your situation because we know nothing about it or what type of configuration/files it saves as.
     
  3. Offline

    mythbusterma

    RingOfStorms BetaNyan

    It won't remove the key in the config, only the value associated with it. Which, in effect, is the same as far as your program is concerned. What I see so many misguided programmers on this forum doing asking this same question because it still remains in the file, even though it has no effect.

    To answer your question, you can open the file using the Java IO libraries and remove it by finding it that way.
     
  4. Offline

    RingOfStorms

    It should indeed remove the key along with the value. When you set it to null the configuration doesn't write anything at all and so the key shouldn't be showing up.
     
  5. Offline

    mythbusterma

    RingOfStorms

    If a key already exists in config, and you set its value to null and save, the key will still be there, with empty braces next to it.
     
  6. Offline

    nopvpgamer

    Code:java
    1. //Its soo Simple !
    2.  
    3. getConfig().set("path", null);
     
  7. Offline

    BetaNyan

    I don't think you read my whole post. Either way I ended up fixing it.
     
Thread Status:
Not open for further replies.

Share This Page