[Utility] HCM - configuration can't be simpler

This is annotation-based utility for mapping config files.

Annotate your class with @ConfigurationContainer and all fields you want to load with @ConfigValue and thats basically all you have to do.
examples: https://github.com/NeumimTo/HoconConfigMapper/tree/master/src/examples/java/example

  • .conf file will be created on a path you specify in the ConfigurationContainer annotation
  • annotated fields must be public and static
  • supports primitives, primitive wrappers, sets, lists and maps
  • in a branch “dev” i started to work on mapping entites, feel free to contribute it you want ill happily accept any prs

also i would like to thank @Favorlock for help.

How would this work for subsections of a config?

Eg:

section: {
    subvalue: true
    subsection: {
        subsectionvalue: "blah"
    }
}

You can use dot notation.

So this seems like a great utility, I can never seem to get configurations to correctly work in my plugins so I was looking for a good utility to use. That being said, when I try to implement, I get the following error

Caused by: com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'playerData'
at com.typesafe.config.impl.SimpleConfig.findKey(SimpleConfig.java:124) ~[SimpleConfig.class:?]
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:145) ~[SimpleConfig.class:?]
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:159) ~[SimpleConfig.class:?]
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:164) ~[SimpleConfig.class:?]
at com.typesafe.config.impl.SimpleConfig.getObject(SimpleConfig.java:218) ~[SimpleConfig.class:?]
at com.typesafe.config.impl.SimpleConfig.getConfig(SimpleConfig.java:224) ~[SimpleConfig.class:?]
at com.typesafe.config.impl.SimpleConfig.getConfig(SimpleConfig.java:33) ~[SimpleConfig.class:?]
at org.cobalt.studios.cobaltim.configuration.ConfigMapper.loadClass(ConfigMapper.java:175) ~[ConfigMapper.class:?]
at org.cobalt.studios.cobaltim.configuration.ConfigManager.initConfig(ConfigManager.java:20) ~[ConfigManager.class:?]
at org.cobalt.studios.cobaltim.configuration.ConfigManager.<init>(ConfigManager.java:14) ~[ConfigManager.class:?]
at org.cobalt.studios.cobaltim.CobaltIM.onServerStart(CobaltIM.java:40) ~[CobaltIM.class:?]
... 30 more

I was searching through the source code to identify the error (the key in question was a Map containing one entry for default values and population. The only difference made was mapping the library classes into main package code. Is there a reason it is not creating or populating correctly? Or is there extra methods I just am missing that are required to be used? I used your example posts on GitHub to setup my Config class so I am curious what I am doing wrong.

Hi,
I guess you added an annotated field to your mapped class after the mapper generated a config file. The mapper wont write missing config sections into the file and thats why this exception is thrown. Im aware of this issue and i plan to fix it.

Strange, I go to the config directory and nothing is there! Not even a folder for my plugin, just standard Forge and Sponge conf’s.

right now Im pushing a small bugfix which might be causing your issue and it also fixes what i wrote above.

I think I have figured my problem out. It seems like the server is not properly injecting the Game dependency into my plugin. Not exactly sure why as I have tried both field injection and method injection and it seems like both do not inject correctly. So I don’t know how to fix that, but it doesn’t seem to be an issue with your library as of yet.