So you may have noticed that serializing things such as items to Configurate, for purposes of configuration, is pretty… bad. Rather than the standard format that you’d see in the /give command, for example, Sponge instead serializes using the DataContainer. This does in fact properly make use of the Data API, but it is very inconvenient for actual configuration. I have therefore started work on a library for easier configuration. Currently I have only completed items, the rest is a WIP. Source
How to use:
To serialize an item to a configuration node, call ItemStackTranslator.convertItem(). To deserialize a configuration node to an item, call ItemStackTranslator.convertNode(). Couldn’t be simpler.
More translators are coming, for common serializables like entities and blocks. This project will stay on top of any data format changes within Sponge.
I do hope this evolves into something useful, but right now it looks like you’re just changing the names of various keys. (Which could be automated pretty easily, instead of doing it manually as you are currently).
Edit:
I really like the concept, and do think these things need to be more descriptive, so I can’t wait to see were this goes
I mean that right now you have lines that switch the literal keys, but you could probably write a function that swaps out x and y key in a configurationnode. Then you could make a factory/builder which returns “swappers” and then have a single static class or a registry that makes key swappers like this.
Not sure how that would help, since the goal is for a single method to do all of the work.
Unless you are misinterpreting the action that the method is doing. The UnsafeData tag is literally the tag tag. This is where everything that isn’t an id, damage, count, or slot goes. And custom data like ForgeData is stored under that as well. So this currently 100% perfectly handles items.
Then you can easily implement all the other translators, without hard-coding each of their tags.
#####Disclaimer: I do not guarantee the above is devoid of bugs, I haven’t tested it, but rather am trying to display my point in a tangible manner
You’re going to need to change your plugin’s name as it’s not affiliated or produced by the Sponge Team. Likewise, I’d refrain from calling what the official supported automatic serialization “bad”. If you wanted to, you could make a PR to the API or implementation to provide some Configurate TypeSerializers for these types so they’re native to the implementation, and not reliant on a plugin library installed.
Addressed the two issues, thinking about the suggestion. It would probably be a good idea to be an official part of the API, that way different implementations can have different formats and still work together.