KyoriPowered / adventure

A user-interface library, formerly known as text, for Minecraft: Java Edition
https://docs.advntr.dev/
MIT License
706 stars 107 forks source link

Kotlin serialization compatibility #839

Open TheFruxz opened 1 year ago

TheFruxz commented 1 year ago

Hey!

I would love to see full compatibility with KotlinX Serialization (JSON), this would definitely help work between Kotlin libraries and adventure.

BomBardyGamer commented 1 year ago

Hey, just noticed this issue and thought I'd comment on it, since I've tried this before. This is actually quite a difficult task to accomplish because of how Kotlin's custom serializers work. The problem is that component serialization needs to be polymorphic over a field in the input data, which wasn't really properly supported the last time I tried (which, admittedly, was quite a while ago, so maybe things have changed since then). The code just kept getting messier and messier and it didn't ever really seem to work with the same consistency as the Gson one built in to Adventure. Someone is welcome to give it another try, but I'm just advising that it may be rather difficult.