This is my attempt at a “simple” (very configurable) plugin, but I’m having troubles with working out how to do it correctly.
I would be grateful for any tips on how to fix the NPE error inside Configurate. Thanks
Project:
error:
This is my attempt at a “simple” (very configurable) plugin, but I’m having troubles with working out how to do it correctly.
I would be grateful for any tips on how to fix the NPE error inside Configurate. Thanks
Project:
error:
Take a look at
https://github.com/SpongePowered/SpongeCommon/blob/master/src/main/java/org/spongepowered/common/config/SpongeConfig.java#L165-L209
That’s Sponge’s own default config.
Basically, ConfigurationSerializable is for data holder objects (such as the catalog types). They need to have a registered builder for them to be created from a config.
You want to be using ObjectMapper to create a “bridge” between your object and your actual config. Note that Sponge’s config actually uses a hierarchy of classes to make the structure a bit easier to read. Just be aware that it’s a bit more complex as they’ve designed it to be for 3 different config types, but the part I’ve highlighted should be all you need to see setup-wise.
If it’s failing here:
https://github.com/zml2008/configurate/blob/master/configurate-core/src/main/java/ninja/leaping/configurate/objectmapping/ObjectMapper.java#L80
then I bet it’s because you are using arrays in your @ConfigSerializable class. Try changing the arrays to lists - that’ll be the simplest thing to do.
When using the @ConfigSerializable annotation, you’re registering the type you’ve annotated, but not the types for each of the @Settings. By default, the types on this page are supported - arrays are not without a custom TypeSerializer. So, the arrays in your config object are not supported - and it fails to map in this way.
There needs to be a nicer exception thrown there.
Pull request it, then.