HOCON settings

So I’m liking the use of HOCON but I have one bone that’s been bugging me. One of the plugins I’ve been working on, the config is moderate in size, I’ve done the best of organization i can do without splitting things into seperate configs, however with HOCON adding items in alphabetical order, it’s still a bit of a headache to quickly navigate. Is this something that can be modified or is it part just part of HOCON’s charm?

It’s nothing to do with HOCON, rather it’s a Configurate issue… you can read more about it here

Interesting…Thanks

Actually, it is a problem of the HOCON implementation configurate is using :smiley:

1 Like

@Zirconium @Saladoc @TrenTech

This issue was addressed in February. What you need to do is pass your own Comparator to the ConfigurationOptions.

Scratch the above, except the issue being addressed. Passing a Comparater object to the ConfigurationOptions is the old method - however, you can still control insertion order via ConfigurationOptions. Take a look at that object.

So far no luck. These are what I’ve tried without success.

ConfigurationLoader<CommentedConfigurationNode> loader = HoconConfigurationLoader.builder().setFile(file).build();
CommentedConfigurationNode config = loader.load();
config.getOptions().setMapFactory(MapFactories.<ConfigurationNode>insertionOrdered());

or

ConfigurationLoader<CommentedConfigurationNode> loader = HoconConfigurationLoader.builder().setFile(file).build();
CommentedConfigurationNode config = loader.load(ConfigurationOptions.default().setMapFactory(MapFactories.<ConfigurationNode>insertionOrdered()));

According to this, the issue lies not within configurate, but with the HOCON implementation re-ordering the keys. While configurate may be able to preserve the insertion order, afaik when writing it to a hocon file, the entries get sorted. Since Sponge is now using java 8, zml may be able to use a newer version where that behavior is configurable.

1 Like

You’re right! It looks like it’s being looked into, now, though, which is fantastic.

1 Like