Skip to content

Instantly share code, notes, and snippets.

@varrix
Created June 11, 2015 23:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save varrix/3a9662ea210b580ef21d to your computer and use it in GitHub Desktop.
Save varrix/3a9662ea210b580ef21d to your computer and use it in GitHub Desktop.
HoconFile example!
private void initConfig() {
// construct our HoconFile object usin
File folder = new File("config", "cortex");
// Params: 1-Super folder of plugin, 2-file name, 3-logger instance
HoconFile config = new HoconFile(folder, "config", logger);
// Optionally can drop the 3rd param (only available for the verbose version)
// if using verbose version, you can toggle verbosity (great for debugging a single file- not recommended for use on ALL files)
config.setVerbose(true);
// creates the file with the boolean true which means it will attempt to merge defaults from a file with the same name
// existing within the JAR (calls HoconFile#mergeDefaults() which ONLY works if the resource exists)
config.create(true);
// simply load the configuration
config.load();
// config.save(); to save (easy nuff!)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment