mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 03:15:35 -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.Registries
|
||||||
import de.bixilon.minosoft.data.registries.registries.registry.RegistryItem
|
import de.bixilon.minosoft.data.registries.registries.registry.RegistryItem
|
||||||
import de.bixilon.minosoft.data.registries.registries.registry.codec.ResourceLocationCodec
|
import de.bixilon.minosoft.data.registries.registries.registry.codec.ResourceLocationCodec
|
||||||
|
import de.bixilon.minosoft.data.text.formatting.color.ChatColors
|
||||||
|
|
||||||
class ChatMessageType(
|
class ChatMessageType(
|
||||||
override val resourceLocation: ResourceLocation,
|
override val resourceLocation: ResourceLocation,
|
||||||
@ -33,11 +34,12 @@ class ChatMessageType(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object : ResourceLocationCodec<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 {
|
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): ChatMessageType {
|
||||||
return ChatMessageType(
|
return ChatMessageType(
|
||||||
resourceLocation = resourceLocation,
|
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) },
|
narration = data["narration"]?.asJsonObject()?.let { TypeProperties.deserialize(it) },
|
||||||
position = data["position"]?.let { ChatTextPositions[it] } ?: ChatTextPositions.CHAT,
|
position = data["position"]?.let { ChatTextPositions[it] } ?: ChatTextPositions.CHAT,
|
||||||
)
|
)
|
||||||
|
@ -25,5 +25,12 @@ enum class ChatParameter {
|
|||||||
companion object : ValuesEnum<ChatParameter> {
|
companion object : ValuesEnum<ChatParameter> {
|
||||||
override val VALUES = values()
|
override val VALUES = values()
|
||||||
override val NAME_MAP: Map<String, ChatParameter> = EnumUtil.getEnumValues(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