##I made a thing that loads values based on what default values you give it.
loadValues() method to load values from a HOCON configuration file, specifying what kind of values you want based on the default values you give.
The types of the objects you set as the default value will be enforced on the value loaded from the configuration file. If it doesn’t match, its rejected. Full documentation in the method jdoc.
dependencies (all in sponge):
- google guava
- slf4j logger
- zml’s configurate
Looks good. I’ll take a better look once I get my computer working
An alternative is the
You can embed a default configuration in the jar (similar to Bukkit plugins) and load it by passing the URL to the config loader.
i have preference for hard-coding my defaults.
plus, this also includes verifying the values as to whether or not they’re acceptable for the plugin to use or not, and includes warning the user of the plugin if the value set in their configuration returns invalid. i wrote it like this aiming to be as end-user idiot-proof as possible, which is usually the rule i set for myself when working with something that can be messed with by the end-user.
Additionally, you could use the object mapper – that way your schema is POJOs rather than yet another format.
i forgot the object mapper was a thing
also, i’m not entirely sure if object mapper lets me implement a verification-type thing; though i can probably do that in the class holding the values.
oh well. what’s done is done