Solved Delete location from configs.

Discussion in 'Plugin Development' started by JavaNaza, Apr 12, 2018.

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

    JavaNaza

    Hey guys, I need some help with configs. What I m trying to do is enough simple but I don't know 1 thing. So I m trying to make a plugin like /sethome. So I know how to set and save that location but I don't know how to delete players home with its name and its location.

    PLAYER's name: Creeper11
    So if the player types command: /newhome MyHome

    The config will look something like this:

    HTML:
    PlayerHomes:
        Creeper11:
            MyHome: "world",100,12,166

    But I don't know how to remove that "MyHome" location and name from the config. And also I don't know how to check if the player has typed home's name correctly that exists in the config.

    Can somebody help me with that?
    Thank you, have a nice day !

    P.S English isn't my nation language so don't blame me for some grammar mistakes.
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    JavaNaza

    ok... but how to check if the player typed the name correctly?
     
  4. Offline

    timtower Administrator Administrator Moderator

    config#contains
     
  5. Offline

    JavaNaza

    Do I need to use for loop?
     
  6. Offline

    timtower Administrator Administrator Moderator

    No, contains returns a boolean
     
  7. Offline

    JavaNaza

    Do I need to show the path like: if(getConfig().contains("PlayerHomes." + playerName + "." + args[0])
    or just if(getConfig().contains(args[0]) ?
     
  8. Offline

    timtower Administrator Administrator Moderator

  9. Offline

    JavaNaza

    Okay, thanks !
     
  10. Offline

    Reflxction

    I'm probably wrong, but I thought this would set its value to "null"? I had this issue once
     
  11. Offline

    timtower Administrator Administrator Moderator

    If the input is a string then probably yes. Otherwise it should remove the section.
     
  12. Offline

    Reflxction

    @timtower forgive me for bumping the thread, but is there any way to avoid that?
     
  13. Offline

    timtower Administrator Administrator Moderator

    To avoid what? Removing the section when you set something to null?
     
  14. Offline

    Reflxction

    @timtower Yes, if it was a string and I want to remove it
     
  15. Offline

    timtower Administrator Administrator Moderator

    Then you set it to null, yml does not know empty things.
     
    Reflxction likes this.
Thread Status:
Not open for further replies.

Share This Page