Solved Delete whole section of config.yml

Discussion in 'Plugin Development' started by Script1996, Aug 9, 2014.

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

    Script1996

    Hey guys,

    I've got a yml which fills up if a special block is placed. After the placement my yml looks like this.

    Code:
    '480634':
      X: 4
      Y: 80
      Z: 634
      Besitzer: Script
    
    and with this code :

    Java.getPlugin().getConfig().getDefaultSection().set(path, null);

    it doesn't delete all. this is always in my yml:

    Code:
    '480634': {}
    how can i delete the whole section include the header "480634" ?

    greez
     
  2. Offline

    xXMaTTHDXx

    Just do something like this:
    Code:
     getConfig().getConfigurationSection(section).set(null);
     
  3. Offline

    Script1996

    I tried

    String path = 480634;
    Java.getPlugin().getConfig().getConfigurationSection(path).set(path,null);

    but it's the same effect like my code :(
     
  4. Offline

    _LB

    This will not work:
    Java.getPlugin().getConfig().getDefaultSection().set(path, null);
    Remove ".getDefaultSection()" and try again.

    This will not work:
    Java.getPlugin().getConfig().getConfigurationSection(path).set(path,null);
    Remove ".getConfigurationSection(path)" and try again.
     
    Script1996 likes this.
  5. Offline

    Script1996

    _LB

    now I got
    Code:java
    1. String path = locX+""+locY+""+locZ;
    2. Java.getPlugin().getConfig().set(path,null);
    3. Java.getPlugin().saveConfig();


    but it wouldn't delete anything from the config.

    I can set the section to an random String and it works. but not "null" an delete the whole section..

    Edit

    Okay thanks bud. this works like a charm. I figured out my fault.

    I added values as default. if "path" = null it uses them ..

    silly me .. thanks for advice :)
     
Thread Status:
Not open for further replies.

Share This Page