Plugin Configuration

As @FerusGrim pointed out, it is unnecessary to explicitly input colons. That may be why some of your nodes are encapsulated in quotes because the “:” character would be illegal.

At the same time, if your node is myNode then retrieving it via config.getNode("myNode:").<some method call> (ie: #getString(…)) would NOT yield a value as the specified node would not be the same since myNode != (isn’t equal to) myNode: (note the colon on the second one).

Also, don’t bother with the spaces, so instead of "myNode: " you should be doing “myNode” just straight up. Configurate (the API you’re using to interact with HOCON formatted files) will take care of formatting and parsing in a HOCON compliant manner.

Also, if you don’t prefer to hardcode the default values and nodes, you can actually just type up a default config, put it in your JAR outside of any directories (unless that is the desired structure you want- but it will require a different way of finding the resource inside of the JAR. Also, if using maven or gradle, put it under /src/main/resources/.

A default config can be named anything you want, although if only using 1 then I’d recommend just naming it config (ie: config.conf). You can then have the default <config name>.conf file be copied from your JAR to the configuration folder. An example of doing something such as that can be found in my resource here: [Resource] HoconFile (not saying you have to use it, just something you might be able to learn off of).

If you didn’t quite understand something I mentioned, please do let me know and I can explain it in more detail, using different terms and/or using different examples with more code snippets.

EDIT 24/09/2015 @ 11:38pm EST
I would also recommend familiarizing yourself with the file format you’re attempting to use (in this case HOCON) as understanding at least some of the basics of how the file is formatted/structured will help you greatly in understanding why issues arise with your configuration.

EDIT 25/09/2015 @ 7:36pm EST
Cleaned up some typos/grammar errors. Also rephrased/elaborated/added detail to some lines to hopefully make it easier to follow.

2 Likes