3

Eg:

"This is a sentence.": "This is the result sentence."

I got an error that the YAML file becomes an empty path if I put a dot behind the key, how can I solve this?

EDIT: I got this error:

java.lang.IllegalArgumentException: Cannot set to an empty path

when using this:

FileConfiguration langPack_EN = YamlConfiguration.loadConfiguration(getResource("lang_EN.yml"));

I was trying to make a language pack, with all translations saved in .yml to be read.

EDIT: Additional information: http://wiki.bukkit.org/Configuration_API_Reference#Paths

Example langPack.yml:

A:
  B: "Value"

Example Code:

String test = langPack_EN.get("A"); //Get B as Object
String test2 = langPack_EN.getString("A.B"); //Get "Value" as String

Is the dot affecting the 'path'? My assumption.

Jordan Running
  • 102,619
  • 17
  • 182
  • 182
Fatty Mieo
  • 39
  • 7
  • Your input is valid as you can test on http://www.yamllint.com/. What do you use to parse it? What exact error do you get? –  Mar 15 '16 at 06:42
  • `java.lang.IllegalArgumentException: Cannot set to an empty path` `FileConfiguration langPack_EN = YamlConfiguration.loadConfiguration(getResource("lang_EN.yml"));` – Fatty Mieo Mar 15 '16 at 06:43
  • Please [edit] your question and include the code and error there. –  Mar 15 '16 at 06:45
  • "Each level is separated by the path separator, which is by default the '.' (period)" So I think your assumtion is correct. –  Mar 15 '16 at 07:18
  • Is there any escapes for that? – Fatty Mieo Mar 15 '16 at 07:19
  • Ask the developers of the library you use. But why do you want dots in keys? –  Mar 15 '16 at 07:20
  • As mentioned, I was making a language pack which some of the sentences are with full stops. – Fatty Mieo Mar 15 '16 at 07:21
  • Maybe with a '\' or something like this before the dot... – LeWimbes Mar 17 '16 at 06:14

1 Answers1

1

You need to change the path separator:

getConfig().options().pathSeparator(',');
gyurix
  • 1,106
  • 9
  • 23