javaminecraftbukkit

config.getstring returns null only if the config has more than 3 "points"


This is my config.yml:

gui:
  title: "This is the GUI's name"
items:
  feather: "This is item feather"
  cookie:
    hello: "Hello, here's a cookie"

And here's the part of code:

String guiTitle = config.getString("gui.title");
String itemsFeather = config.getString("items.feather"); 
String itemsOnTest = config.getString("items.cookie.hello");

getLogger().info("Gui title: " + guiTitle);
getLogger().info("Items feather: " + itemsFeather);
getLogger().info("Items on test: " + itemsOnTest);

The first 2 getLoggers show the correct text from the config, while itemsOnTest returns null. As long as I use 2 "names" in the config like:

Example 1:
  test: "This is a test"

It works and shows the "This is a test", while if it's more than 2 like this:

items:
  on:
    test: "hello"

Then items.on.test won't show "hello" but null.


Solution

  • Key as on/off/true/false seems to be reserved keyword, and create issue. It's not because of 3 steps.

    I simply suggest you to change the keyword used to something like enabled, and this should works fine.