#How to set keys with periods in them with FileConfigurations

1 messages · Page 1 of 1 (latest)

severe socket
#

Hey guys! I'm working with FileConfigurations here, and I want to set a key that contains periods in it For example:

key1:
  key2.with.a.long.name: "value"

But when I use
config.setString("key1.key2.with.a.long.name", "value") It'll turn into the following instead:

key1:
  key2:
    with:
      a:
        long:
          name: "value

Is there some way to get around this?

warped pine
#

Yep

#

FileConfiguration::options

#

Then FileConfigurationOptions::pathSeparator and pass something which is not .

crystal raptor
#

u could set the seperator to / for example and then use key1/key2.with.a.long.name

warped pine
severe socket
#

Oh nice! I didn't know about that, thank you so much :D

warped pine
hexed zinc
#

TIL

severe socket
#

Modifying the config file now works! But every time I load the config file it re-formats it with the previous separation type. This is how I'm loading the file:

 public static FileConfiguration loadData(String folder, String name) {
        File file = new File(new File(rootFolder, folder), name + ".yml");
        return YamlConfiguration.loadConfiguration(file).options().pathSeparator('/').configuration();
    }

Am I doing something wrong here? :)