remove a config path

Discussion in 'Spigot Plugin Development' started by WurstMichel, Apr 30, 2017.

  1. Hello I want to code a plugin for Minecraft and I have a problem.
    I want to remove in the config a path without using: this.getconfig.set("path", null).
    I donĀ“t want to use null.
     
  2. And why don't you want to use null? I don't think there's another way to do this.
     
  3. sothatsit

    Patron

    Too bad. There are no alternatives. This is how the API is written.
     
  4. Null is the best choice. Setting it to null will remove current value of path, or path
     
  5. If I use null there is no way to query whether it is null I believe.

    And if I want to read from the config a string and then check to see if it is null, then it still gives me a nullpointerexception.
     
    #5 WurstMichel, Apr 30, 2017
    Last edited: Apr 30, 2017
  6. sothatsit

    Patron

    Setting it to null removes it. Thus, isSet will return false afterwards.
     
  7. but if I use null then in the config its look like:
    path: {}
     
  8. sothatsit

    Patron

    It shouldn't. Not if you are setting path to null.
     
  9. I have:
    this.getConfig.addDefault(path1.path2, null);
    if (this.getConfig.getString(path1.path2) != null) { //here is the nullpointerexception
    blablabla
    }
     
  10. sothatsit

    Patron

    That code would not compile. Show us the code you actually use.
     
  11. oh, now ist work.
    I have changed a little bit of the code and now it works

    thx