From ceb60e3c6a1fd4859beffc43d1afd0b7680b8e8f Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 18 Feb 2021 00:38:18 +0600 Subject: [PATCH] make plugin more correctly serializable --- plugin/src/main/kotlin/dev/inmo/plagubot/PluginSerializer.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin/src/main/kotlin/dev/inmo/plagubot/PluginSerializer.kt b/plugin/src/main/kotlin/dev/inmo/plagubot/PluginSerializer.kt index 26b1de2..b21c7e7 100644 --- a/plugin/src/main/kotlin/dev/inmo/plagubot/PluginSerializer.kt +++ b/plugin/src/main/kotlin/dev/inmo/plagubot/PluginSerializer.kt @@ -45,7 +45,9 @@ object PluginSerializer : KSerializer { } } + @InternalSerializationApi override fun serialize(encoder: Encoder, value: Plugin) { - polymorphic.serialize(encoder, value) + val serializer = (value::class.serializerOrNull() ?: polymorphic) as KSerializer + serializer.serialize(encoder, value) } } \ No newline at end of file