I'm working on migrating some of my code from raw JSON parsing to Codecs, the way how I have done the code kind of brings me some issues with that approach
I'm also changing how the config looks, the 1st image is the current config and the 2nd one is the new planned one
roles and type are common to all objects in entries, execute and on_join are optional, and it's content varies depending on the type
each type has it's class, and it's own codec.
I wanted to have a Codec in BaseEntry, the abstract super class, that gives the correct child class from Codec#parse and gives the full JSON object from Codec#encode
BaseEntry needs the roles when initialised, currently I also take the type too, so it can be encoded back
I can also change the config structure, but my goal is to have it easier for users to understand
So I want to know if there is a way to have one codec to do the stuff. I also want to allow one to use the child class' codec to encode and decode
in other words, BaseEntry.CODEC.parse gives me a child of BaseEntry and (for example) CommandEntry.CODEC.encode to give me
{
"roles": ["744941527545020468"],
"type": "autowhitelist:team",
"on_join": true,
"execute": {
"on_add": "give {player} diamond 1",
"on_remove": "scoreboard players set cool_score {player} 0"
}
}