Asthetics in Configurations

So without all the technical stuff that’s posted online can someone give an example of a ‘beautiful’ config? because i want something a bit more easy to navigate…and this is a jumbled mess :slight_smile: thank you

try {
configFile.createNewFile();
loadConfig();
config.getNode(“Explosions”).setComment(“Disable or Enable These Explosion Types? True = No Explosions || False = Explosions”);
config.getNode(“Explosions”, “TNT”).setValue(“true”);
config.getNode(“Explosions”, “Creeper”).setValue(“true”);
config.getNode(“Explosions”, “Ghast”).setValue(“true”);
config.getNode(“Undo?”).setComment(“Would you like any damage to be undone? YES = Undoes damage || NO = Damage is permenate”);
config.getNode(“Undo?”, “Undo_Creeper_Explosiong”).setValue(“yes”);
config.getNode(“Undo?”, “Creeper’s_Rollback_Time”).setComment(“in Seconds”).setValue(“5”);
config.getNode(“Undo?”, “UndoTNT)_Explosiong”).setValue(“yes”);
config.getNode(“Undo?”, “TNT’s_Rollback_Time”).setComment(“in Seconds”).setValue(“10”);
config.getNode(“Undo?”, “Undo_Ghast’s_Explosion”).setValue(“yes”);
config.getNode(“Undo?”, “Ghast_Rollback_Time”).setValue(“10”);
config.getNode(“DropItems_Creeper”).setComment(“Do you want Creeper Explosions to Drop Items? YES = true || NO = false”).setValue(“false”);
config.getNode(“DropItems_TNT”).setComment(“Do you want TNT Explosions to Drop Items? YES = true || NO = false”).setValue(“false”);
config.getNode(“DropItems_Ghast”).setComment(“Do you want Ghast Explosions to Drop Items? YES = true || NO = false”).setValue(“false”);
saveConfig();
}

Load a default config from src/main/resources.

Example:

ConfigurationLoader yourLoader;
ConfigurationNode yourNode;

ConfigurationLoader defaultLoader = HoconConfigurationLoader.builder().setUrl(this.getClass().getResource("config.conf");

yourNode.mergeValuesFrom(defaultLoader.load());
yourLoader.save(yourNode);
1 Like
ConfigMapper.init("Your plugin", getPathToPluginJar());
ConfigMapper.get("Your plugin").loadClass(PluginConfig.class); //creates a config file with default values if it does not exist

@ConfigurationContainer(filename = "Config.conf")
public class PluginConfig{

    @Comment(content = {"an example"})
    @ConfigValue(name = "ListOfStrings")                          //defaults
    public static List<String> stringList = new Vector<String>(Arrays.asList("A","B","C"));

}
2 Likes