Solved How to add strings in config.yml

Discussion in 'Spigot Plugin Development' started by Nico12, Jan 23, 2020.

  1. Although the title already speaks a lot about what this thread is about, my problem is that when executing this command the player's name is added to a path of the config.yml
    Example:
    Code (Text):

    MyPlugin:
      Players:
        X_John41:
     
    I know it seems like a very novice doubt but this drove me crazy all day.
    Thanks in advance
     
  2. The path is a string so you can just concatenate “testpath” + “the argument that has the player name”

    And then save the file.
     
  3. Could you give an example?
     
  4. There is a method in YamlConfiguration that allows you to create a section. The parameter should be a String, so you could just do the concatenation in the parameter.

    It would be something like methodName(“thing.”+name) where name is one of the arguments in the command.
    The result could be:

    thing:
    Plochem:​
     
  5. Working! Thanks. Resolved