Solved Deleting key completely from the config.yml

Discussion in 'Plugin Development' started by CGA1123, May 27, 2014.

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

    CGA1123

    Hey, I was wondering if this was possible and if so, how?
    I know about the config.set(KEY, null), however this set the value to null, it does not delete the actual key.

    What I mean:
    Code:java
    1.  
    2. key:
    3. derp: herp
    4. herp: derp
    5.  
    6. key1:
    7. derp: herp
    8. herp: derp
    9.  


    I would like to be able to totally delete the 'key:' and all its children
    ie it would then look like this:
    Code:java
    1.  
    2. key1:
    3. derp: herp
    4. herp: derp
    5.  


    Thanks!
     
  2. Offline

    metalhedd

    I'm 99.99999% sure that setting it to null DOES totally delete the key and all it's children. have you confirmed waht you say is correct?
     
  3. Offline

    minoneer


    Quote from the Bukkit Java Docs:

    So it should actually work.
     
  4. Offline

    CGA1123

    metalhedd minoneer
    Yes from what I have tried.
    what happens is that it deletes all the children however the key remains,
    I will re-check my code again...

    Code:java
    1. this.getConfig().set(args[0], null);

    This should work, right?

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

    minoneer

    if args[0] is your config path then yes, it should

    Edit: you are saving the config after modifying it right?
     
  6. Offline

    CGA1123

    minoneer

    Found the error, did args[0].toString() and it worked!

    Thanks for the quick replies btw!
     
  7. Offline

    metalhedd

    assuming args comes from an onCommand handler, then args[0] was already a string, adding .toString() does absolutely nothing. you must've done something else that inadvertently solved your problem
     
  8. Offline

    CGA1123

    metalhedd
    Yeah it seems I accidentally solved my problem, I just checked and it works fine now without the .toString().
    hm...

    Anyways thanks for your help!
     
Thread Status:
Not open for further replies.

Share This Page