mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 10:55:01 -04:00
1.19: fix chat message type reading
This commit is contained in:
parent
9cce1cbf61
commit
fa475eebb5
@ -20,6 +20,7 @@ import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||
import de.bixilon.minosoft.data.registries.registries.registry.RegistryItem
|
||||
import de.bixilon.minosoft.data.registries.registries.registry.codec.ResourceLocationCodec
|
||||
import de.bixilon.minosoft.data.text.formatting.color.ChatColors
|
||||
|
||||
class ChatMessageType(
|
||||
override val resourceLocation: ResourceLocation,
|
||||
@ -33,11 +34,12 @@ class ChatMessageType(
|
||||
}
|
||||
|
||||
companion object : ResourceLocationCodec<ChatMessageType> {
|
||||
private val DEFAULT_PROPERTIES = TypeProperties("[%s] %s", listOf(ChatParameter.SENDER, ChatParameter.SENDER), mapOf("color" to ChatColors.GRAY))
|
||||
|
||||
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): ChatMessageType {
|
||||
return ChatMessageType(
|
||||
resourceLocation = resourceLocation,
|
||||
chat = data["chat"].asJsonObject().let { TypeProperties.deserialize(it) },
|
||||
chat = data["chat"]?.asJsonObject()?.let { TypeProperties.deserialize(it) } ?: DEFAULT_PROPERTIES,
|
||||
narration = data["narration"]?.asJsonObject()?.let { TypeProperties.deserialize(it) },
|
||||
position = data["position"]?.let { ChatTextPositions[it] } ?: ChatTextPositions.CHAT,
|
||||
)
|
||||
|
@ -25,5 +25,12 @@ enum class ChatParameter {
|
||||
companion object : ValuesEnum<ChatParameter> {
|
||||
override val VALUES = values()
|
||||
override val NAME_MAP: Map<String, ChatParameter> = EnumUtil.getEnumValues(VALUES)
|
||||
|
||||
override fun get(name: String): ChatParameter {
|
||||
return when (name.lowercase()) {
|
||||
"team_name" -> TARGET
|
||||
else -> super.get(name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user