mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 11:54:59 -04:00
load message type registry
This commit is contained in:
parent
458069de1d
commit
e99f47b845
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020-2022 Moritz Zwerger and contributors
|
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
@ -13,24 +13,10 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.data.chat.type
|
package de.bixilon.minosoft.data.chat.type
|
||||||
|
|
||||||
import de.bixilon.kutil.enums.EnumUtil
|
import de.bixilon.minosoft.util.KUtil.minecraft
|
||||||
import de.bixilon.kutil.enums.ValuesEnum
|
|
||||||
import de.bixilon.minosoft.data.chat.ChatTextPositions
|
|
||||||
|
|
||||||
enum class DefaultMessageTypes(val position: ChatTextPositions = ChatTextPositions.CHAT) {
|
object DefaultMessageTypes {
|
||||||
CHAT_MESSAGE,
|
val CHAT = minecraft("chat")
|
||||||
SYSTEM_MESSAGE,
|
val SYSTEM = minecraft("system")
|
||||||
GAME_MESSAGE,
|
val GAME = minecraft("game")
|
||||||
|
|
||||||
COMMAND_SAY,
|
|
||||||
COMMAND_MSG,
|
|
||||||
COMMAND_TEAM_MSG,
|
|
||||||
COMMAND_EMOTE,
|
|
||||||
COMMAND_TELLRAW,
|
|
||||||
;
|
|
||||||
|
|
||||||
companion object : ValuesEnum<DefaultMessageTypes> {
|
|
||||||
override val VALUES: Array<DefaultMessageTypes> = values()
|
|
||||||
override val NAME_MAP: Map<String, DefaultMessageTypes> = EnumUtil.getEnumValues(VALUES)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Minosoft
|
* Minosoft
|
||||||
* Copyright (C) 2020-2022 Moritz Zwerger and contributors
|
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
*
|
*
|
||||||
@ -13,11 +13,12 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.data.chat.type
|
package de.bixilon.minosoft.data.chat.type
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.data.registries.chat.ChatMessageType
|
||||||
import de.bixilon.minosoft.data.text.ChatComponent
|
import de.bixilon.minosoft.data.text.ChatComponent
|
||||||
|
|
||||||
@Deprecated("Refactor")
|
@Deprecated("Refactor")
|
||||||
class MessageType(
|
class MessageType(
|
||||||
val id: Int,
|
val type: ChatMessageType,
|
||||||
val text: ChatComponent,
|
val text: ChatComponent,
|
||||||
val targetName: ChatComponent?,
|
val targetName: ChatComponent?,
|
||||||
)
|
)
|
||||||
|
@ -22,6 +22,7 @@ import de.bixilon.minosoft.data.entities.EntityAnimations
|
|||||||
import de.bixilon.minosoft.data.entities.EntityObjectType
|
import de.bixilon.minosoft.data.entities.EntityObjectType
|
||||||
import de.bixilon.minosoft.data.entities.block.BlockDataDataType
|
import de.bixilon.minosoft.data.entities.block.BlockDataDataType
|
||||||
import de.bixilon.minosoft.data.entities.data.types.EntityDataTypes
|
import de.bixilon.minosoft.data.entities.data.types.EntityDataTypes
|
||||||
|
import de.bixilon.minosoft.data.registries.chat.ChatMessageType
|
||||||
import de.bixilon.minosoft.data.registries.entities.variants.CatVariant
|
import de.bixilon.minosoft.data.registries.entities.variants.CatVariant
|
||||||
import de.bixilon.minosoft.data.registries.other.containers.ContainerType
|
import de.bixilon.minosoft.data.registries.other.containers.ContainerType
|
||||||
import de.bixilon.minosoft.data.registries.registries.registry.PerVersionEnumRegistry
|
import de.bixilon.minosoft.data.registries.registries.registry.PerVersionEnumRegistry
|
||||||
@ -30,6 +31,7 @@ import de.bixilon.minosoft.data.registries.registries.registry.Registry
|
|||||||
import de.bixilon.minosoft.data.registries.registries.registry.ResourceLocationRegistry
|
import de.bixilon.minosoft.data.registries.registries.registry.ResourceLocationRegistry
|
||||||
import de.bixilon.minosoft.protocol.packets.c2s.play.entity.EntityActionC2SP
|
import de.bixilon.minosoft.protocol.packets.c2s.play.entity.EntityActionC2SP
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.play.title.TitleS2CF
|
import de.bixilon.minosoft.protocol.packets.s2c.play.title.TitleS2CF
|
||||||
|
import de.bixilon.minosoft.util.KUtil.minecraft
|
||||||
import de.bixilon.minosoft.util.json.ResourceLocationJsonMap.toResourceLocationMap
|
import de.bixilon.minosoft.util.json.ResourceLocationJsonMap.toResourceLocationMap
|
||||||
import de.bixilon.minosoft.util.logging.Log
|
import de.bixilon.minosoft.util.logging.Log
|
||||||
import de.bixilon.minosoft.util.logging.LogLevels
|
import de.bixilon.minosoft.util.logging.LogLevels
|
||||||
@ -66,6 +68,9 @@ object DefaultRegistries {
|
|||||||
val CAT_VARIANT_REGISTRY: PerVersionRegistry<CatVariant, Registry<CatVariant>> = PerVersionRegistry { Registry(codec = CatVariant) }
|
val CAT_VARIANT_REGISTRY: PerVersionRegistry<CatVariant, Registry<CatVariant>> = PerVersionRegistry { Registry(codec = CatVariant) }
|
||||||
|
|
||||||
|
|
||||||
|
val MESSAGE_TYPES_REGISTRY: PerVersionRegistry<ChatMessageType, Registry<ChatMessageType>> = PerVersionRegistry { Registry(codec = ChatMessageType) }
|
||||||
|
|
||||||
|
|
||||||
fun load(latch: CountUpAndDownLatch) {
|
fun load(latch: CountUpAndDownLatch) {
|
||||||
check(!initialized) { "Already initialized!" }
|
check(!initialized) { "Already initialized!" }
|
||||||
Log.log(LogMessageType.OTHER, LogLevels.VERBOSE) { "Loading default registries..." }
|
Log.log(LogMessageType.OTHER, LogLevels.VERBOSE) { "Loading default registries..." }
|
||||||
@ -101,6 +106,8 @@ object DefaultRegistries {
|
|||||||
|
|
||||||
CAT_VARIANT_REGISTRY.initialize(registriesJson[ResourceLocation("variants/cat")].asJsonObject(), CatVariant)
|
CAT_VARIANT_REGISTRY.initialize(registriesJson[ResourceLocation("variants/cat")].asJsonObject(), CatVariant)
|
||||||
|
|
||||||
|
MESSAGE_TYPES_REGISTRY.initialize(registriesJson[minecraft("message_types")].asJsonObject(), ChatMessageType)
|
||||||
|
|
||||||
initialized = true
|
initialized = true
|
||||||
Log.log(LogMessageType.OTHER, LogLevels.VERBOSE) { "Loaded default registries!" }
|
Log.log(LogMessageType.OTHER, LogLevels.VERBOSE) { "Loaded default registries!" }
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.data.registries.chat
|
||||||
|
|
||||||
|
import de.bixilon.kutil.json.JsonObject
|
||||||
|
import de.bixilon.kutil.json.JsonUtil.asJsonObject
|
||||||
|
import de.bixilon.minosoft.data.chat.ChatTextPositions
|
||||||
|
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
|
||||||
|
|
||||||
|
class ChatMessageType(
|
||||||
|
override val resourceLocation: ResourceLocation,
|
||||||
|
val chat: TypeProperties,
|
||||||
|
val narration: TypeProperties?,
|
||||||
|
val position: ChatTextPositions,
|
||||||
|
) : RegistryItem() {
|
||||||
|
|
||||||
|
companion object : ResourceLocationCodec<ChatMessageType> {
|
||||||
|
|
||||||
|
override fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): ChatMessageType {
|
||||||
|
return ChatMessageType(
|
||||||
|
resourceLocation = resourceLocation,
|
||||||
|
chat = data["chat"].asJsonObject().let { TypeProperties.deserialize(it) },
|
||||||
|
narration = data["chat"]?.asJsonObject()?.let { TypeProperties.deserialize(it) },
|
||||||
|
position = data["position"]?.let { ChatTextPositions[it] } ?: ChatTextPositions.CHAT,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.data.registries.chat
|
||||||
|
|
||||||
|
import de.bixilon.kutil.enums.EnumUtil
|
||||||
|
import de.bixilon.kutil.enums.ValuesEnum
|
||||||
|
|
||||||
|
enum class ChatParameter {
|
||||||
|
TARGET,
|
||||||
|
SENDER,
|
||||||
|
CONTENT,
|
||||||
|
;
|
||||||
|
|
||||||
|
companion object : ValuesEnum<ChatParameter> {
|
||||||
|
override val VALUES = values()
|
||||||
|
override val NAME_MAP: Map<String, ChatParameter> = EnumUtil.getEnumValues(VALUES)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Minosoft
|
||||||
|
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.data.registries.chat
|
||||||
|
|
||||||
|
import de.bixilon.kutil.json.JsonObject
|
||||||
|
import de.bixilon.kutil.json.JsonUtil.asJsonList
|
||||||
|
import de.bixilon.kutil.json.JsonUtil.asJsonObject
|
||||||
|
|
||||||
|
class TypeProperties(
|
||||||
|
val translationKey: String,
|
||||||
|
val parameters: List<ChatParameter>,
|
||||||
|
val style: Map<String, Any>,
|
||||||
|
) {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
fun deserialize(data: JsonObject): TypeProperties {
|
||||||
|
val key = data["translation_key"]!!.toString()
|
||||||
|
var parameters: List<ChatParameter> = emptyList()
|
||||||
|
|
||||||
|
data["parameters"]?.asJsonList()?.let {
|
||||||
|
val list: MutableList<ChatParameter> = mutableListOf()
|
||||||
|
for (entry in it) {
|
||||||
|
list += ChatParameter[entry.toString()]
|
||||||
|
}
|
||||||
|
parameters = list
|
||||||
|
}
|
||||||
|
val style = data["style"]?.asJsonObject() ?: emptyMap()
|
||||||
|
|
||||||
|
return TypeProperties(key, parameters, style)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -34,6 +34,7 @@ import de.bixilon.minosoft.data.registries.biomes.BiomeCategory
|
|||||||
import de.bixilon.minosoft.data.registries.biomes.BiomePrecipitation
|
import de.bixilon.minosoft.data.registries.biomes.BiomePrecipitation
|
||||||
import de.bixilon.minosoft.data.registries.blocks.entites.BlockEntityTypeRegistry
|
import de.bixilon.minosoft.data.registries.blocks.entites.BlockEntityTypeRegistry
|
||||||
import de.bixilon.minosoft.data.registries.blocks.types.Block
|
import de.bixilon.minosoft.data.registries.blocks.types.Block
|
||||||
|
import de.bixilon.minosoft.data.registries.chat.ChatMessageType
|
||||||
import de.bixilon.minosoft.data.registries.dimension.Dimension
|
import de.bixilon.minosoft.data.registries.dimension.Dimension
|
||||||
import de.bixilon.minosoft.data.registries.effects.StatusEffect
|
import de.bixilon.minosoft.data.registries.effects.StatusEffect
|
||||||
import de.bixilon.minosoft.data.registries.enchantment.Enchantment
|
import de.bixilon.minosoft.data.registries.enchantment.Enchantment
|
||||||
@ -121,6 +122,7 @@ class Registries {
|
|||||||
val worldEventRegistry: ResourceLocationRegistry = ResourceLocationRegistry()
|
val worldEventRegistry: ResourceLocationRegistry = ResourceLocationRegistry()
|
||||||
|
|
||||||
val argumentTypeRegistry: ResourceLocationRegistry = ResourceLocationRegistry()
|
val argumentTypeRegistry: ResourceLocationRegistry = ResourceLocationRegistry()
|
||||||
|
val messageTypeRegistry: Registry<ChatMessageType> = register("chat_type", Registry(codec = ChatMessageType))
|
||||||
|
|
||||||
var isFullyLoaded = false
|
var isFullyLoaded = false
|
||||||
private set
|
private set
|
||||||
@ -173,6 +175,7 @@ class Registries {
|
|||||||
worker += WorkerTask(this::gameEventRegistry) { gameEventRegistry.rawUpdate(pixlyzerData["game_events"]?.toJsonObject(), this) }
|
worker += WorkerTask(this::gameEventRegistry) { gameEventRegistry.rawUpdate(pixlyzerData["game_events"]?.toJsonObject(), this) }
|
||||||
worker += WorkerTask(this::worldEventRegistry) { worldEventRegistry.rawUpdate(pixlyzerData["world_events"]?.toJsonObject(), this) }
|
worker += WorkerTask(this::worldEventRegistry) { worldEventRegistry.rawUpdate(pixlyzerData["world_events"]?.toJsonObject(), this) }
|
||||||
worker += WorkerTask(this::argumentTypeRegistry) { argumentTypeRegistry.rawUpdate(pixlyzerData["argument_type"]?.toJsonObject(), this) }
|
worker += WorkerTask(this::argumentTypeRegistry) { argumentTypeRegistry.rawUpdate(pixlyzerData["argument_type"]?.toJsonObject(), this) }
|
||||||
|
worker += WorkerTask(this::messageTypeRegistry) { messageTypeRegistry.rawUpdate(pixlyzerData["message_types"]?.toJsonObject(), this) }
|
||||||
|
|
||||||
|
|
||||||
worker += WorkerTask(this::entityTypeRegistry) { entityTypeRegistry.rawUpdate(pixlyzerData["entities"]?.toJsonObject(), this) }
|
worker += WorkerTask(this::entityTypeRegistry) { entityTypeRegistry.rawUpdate(pixlyzerData["entities"]?.toJsonObject(), this) }
|
||||||
|
@ -48,6 +48,7 @@ object RegistriesLoader {
|
|||||||
registries.titleActionsRegistry.parent = DefaultRegistries.TITLE_ACTIONS_REGISTRY.forVersion(version)
|
registries.titleActionsRegistry.parent = DefaultRegistries.TITLE_ACTIONS_REGISTRY.forVersion(version)
|
||||||
registries.entityAnimationRegistry.parent = DefaultRegistries.ENTITY_ANIMATION_REGISTRY.forVersion(version)
|
registries.entityAnimationRegistry.parent = DefaultRegistries.ENTITY_ANIMATION_REGISTRY.forVersion(version)
|
||||||
registries.entityActionsRegistry.parent = DefaultRegistries.ENTITY_ACTIONS_REGISTRY.forVersion(version)
|
registries.entityActionsRegistry.parent = DefaultRegistries.ENTITY_ACTIONS_REGISTRY.forVersion(version)
|
||||||
|
registries.messageTypeRegistry.parent = DefaultRegistries.MESSAGE_TYPES_REGISTRY.forVersion(version)
|
||||||
|
|
||||||
registries.containerTypeRegistry.parent = DefaultRegistries.CONTAINER_TYPE_REGISTRY.forVersion(version)
|
registries.containerTypeRegistry.parent = DefaultRegistries.CONTAINER_TYPE_REGISTRY.forVersion(version)
|
||||||
registries.gameEventRegistry.parent = DefaultRegistries.GAME_EVENT_REGISTRY.forVersion(version)
|
registries.gameEventRegistry.parent = DefaultRegistries.GAME_EVENT_REGISTRY.forVersion(version)
|
||||||
|
@ -13,9 +13,10 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.data.registries.registries.registry.codec
|
package de.bixilon.minosoft.data.registries.registries.registry.codec
|
||||||
|
|
||||||
|
import de.bixilon.kutil.json.JsonObject
|
||||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||||
import de.bixilon.minosoft.data.registries.registries.Registries
|
import de.bixilon.minosoft.data.registries.registries.Registries
|
||||||
|
|
||||||
interface ResourceLocationCodec<T> {
|
interface ResourceLocationCodec<T> {
|
||||||
fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: Map<String, Any>): T?
|
fun deserialize(registries: Registries?, resourceLocation: ResourceLocation, data: JsonObject): T?
|
||||||
}
|
}
|
||||||
|
@ -233,7 +233,7 @@ class DebugHUDElement(guiRenderer: GUIRenderer) : Element(guiRenderer), Layouted
|
|||||||
layout += LineSpacerElement(guiRenderer)
|
layout += LineSpacerElement(guiRenderer)
|
||||||
|
|
||||||
MinosoftPropertiesLoader.apply {
|
MinosoftPropertiesLoader.apply {
|
||||||
layout += TextElement(guiRenderer, "Git ${it.commit}/${it.branch}", HorizontalAlignments.RIGHT)
|
layout += TextElement(guiRenderer, "Git ${it.commitShort}/${it.branch}", HorizontalAlignments.RIGHT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
package de.bixilon.minosoft.modding.event.events
|
package de.bixilon.minosoft.modding.event.events
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.chat.type.DefaultMessageTypes
|
import de.bixilon.minosoft.data.chat.type.DefaultMessageTypes
|
||||||
|
import de.bixilon.minosoft.data.registries.chat.ChatMessageType
|
||||||
import de.bixilon.minosoft.data.text.ChatComponent
|
import de.bixilon.minosoft.data.text.ChatComponent
|
||||||
import de.bixilon.minosoft.modding.event.EventInitiators
|
import de.bixilon.minosoft.modding.event.EventInitiators
|
||||||
import de.bixilon.minosoft.modding.event.events.connection.play.PlayConnectionEvent
|
import de.bixilon.minosoft.modding.event.events.connection.play.PlayConnectionEvent
|
||||||
@ -26,14 +27,14 @@ class ChatMessageReceiveEvent(
|
|||||||
connection: PlayConnection,
|
connection: PlayConnection,
|
||||||
initiator: EventInitiators,
|
initiator: EventInitiators,
|
||||||
val message: ChatComponent,
|
val message: ChatComponent,
|
||||||
val type: DefaultMessageTypes,
|
val type: ChatMessageType,
|
||||||
val sender: UUID?,
|
val sender: UUID?,
|
||||||
) : PlayConnectionEvent(connection, initiator), CancelableEvent {
|
) : PlayConnectionEvent(connection, initiator), CancelableEvent {
|
||||||
|
|
||||||
|
|
||||||
constructor(connection: PlayConnection, packet: ChatMessageS2CP) : this(connection, EventInitiators.SERVER, packet.message, packet.type, packet.sender)
|
constructor(connection: PlayConnection, packet: ChatMessageS2CP) : this(connection, EventInitiators.SERVER, packet.message, packet.type, packet.sender)
|
||||||
|
|
||||||
constructor(connection: PlayConnection, packet: HotbarTextS2CP) : this(connection, EventInitiators.SERVER, packet.text, DefaultMessageTypes.GAME_MESSAGE, null)
|
constructor(connection: PlayConnection, packet: HotbarTextS2CP) : this(connection, EventInitiators.SERVER, packet.text, connection.registries.messageTypeRegistry[DefaultMessageTypes.GAME]!!, null)
|
||||||
|
|
||||||
constructor(connection: PlayConnection, packet: SignedChatMessageS2CP) : this(connection, EventInitiators.SERVER, packet.message.body.text, DefaultMessageTypes.CHAT_MESSAGE, packet.message.header.sender)
|
constructor(connection: PlayConnection, packet: SignedChatMessageS2CP) : this(connection, EventInitiators.SERVER, packet.message.body.text, connection.registries.messageTypeRegistry[DefaultMessageTypes.CHAT]!!, packet.message.header.sender)
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
package de.bixilon.minosoft.protocol.packets.s2c.play.chat
|
package de.bixilon.minosoft.protocol.packets.s2c.play.chat
|
||||||
|
|
||||||
import de.bixilon.minosoft.data.chat.type.DefaultMessageTypes
|
import de.bixilon.minosoft.data.chat.type.DefaultMessageTypes
|
||||||
|
import de.bixilon.minosoft.data.registries.chat.ChatMessageType
|
||||||
import de.bixilon.minosoft.data.text.ChatComponent
|
import de.bixilon.minosoft.data.text.ChatComponent
|
||||||
import de.bixilon.minosoft.modding.event.events.ChatMessageReceiveEvent
|
import de.bixilon.minosoft.modding.event.events.ChatMessageReceiveEvent
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||||
@ -29,7 +30,7 @@ import java.util.*
|
|||||||
@LoadPacket(threadSafe = false)
|
@LoadPacket(threadSafe = false)
|
||||||
class ChatMessageS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
class ChatMessageS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
||||||
val message: ChatComponent = buffer.readChatComponent()
|
val message: ChatComponent = buffer.readChatComponent()
|
||||||
var type: DefaultMessageTypes = DefaultMessageTypes.CHAT_MESSAGE
|
var type: ChatMessageType = buffer.connection.registries.messageTypeRegistry[DefaultMessageTypes.CHAT]!!
|
||||||
private set
|
private set
|
||||||
var sender: UUID? = null
|
var sender: UUID? = null
|
||||||
private set
|
private set
|
||||||
@ -41,7 +42,7 @@ class ChatMessageS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
|
|||||||
if (buffer.versionId >= ProtocolVersions.V_1_19_1_PRE2) {
|
if (buffer.versionId >= ProtocolVersions.V_1_19_1_PRE2) {
|
||||||
overlay = buffer.readBoolean()
|
overlay = buffer.readBoolean()
|
||||||
} else {
|
} else {
|
||||||
type = DefaultMessageTypes[buffer.readVarInt()]
|
type = buffer.readRegistryItem(buffer.connection.registries.messageTypeRegistry)
|
||||||
if (buffer.versionId >= ProtocolVersions.V_20W21A && buffer.versionId < ProtocolVersions.V_22W17A) {
|
if (buffer.versionId >= ProtocolVersions.V_20W21A && buffer.versionId < ProtocolVersions.V_22W17A) {
|
||||||
sender = buffer.readUUID()
|
sender = buffer.readUUID()
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ import de.bixilon.minosoft.commands.suggestion.factory.SuggestionFactories
|
|||||||
import de.bixilon.minosoft.data.chat.filter.ChatFilter
|
import de.bixilon.minosoft.data.chat.filter.ChatFilter
|
||||||
import de.bixilon.minosoft.data.chat.filter.Filter
|
import de.bixilon.minosoft.data.chat.filter.Filter
|
||||||
import de.bixilon.minosoft.data.chat.signature.*
|
import de.bixilon.minosoft.data.chat.signature.*
|
||||||
import de.bixilon.minosoft.data.chat.type.DefaultMessageTypes
|
|
||||||
import de.bixilon.minosoft.data.chat.type.MessageType
|
import de.bixilon.minosoft.data.chat.type.MessageType
|
||||||
import de.bixilon.minosoft.data.container.ItemStackUtil
|
import de.bixilon.minosoft.data.container.ItemStackUtil
|
||||||
import de.bixilon.minosoft.data.container.stack.ItemStack
|
import de.bixilon.minosoft.data.container.stack.ItemStack
|
||||||
@ -384,14 +383,14 @@ class PlayInByteBuffer : InByteBuffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun readMessageType(): MessageType {
|
fun readMessageType(): MessageType {
|
||||||
return MessageType(readVarInt(), readChatComponent(), readOptional { readChatComponent() })
|
return MessageType(readRegistryItem(connection.registries.messageTypeRegistry), readChatComponent(), readOptional { readChatComponent() })
|
||||||
}
|
}
|
||||||
|
|
||||||
fun readSignedMessage(): SignedMessage {
|
fun readSignedMessage(): SignedMessage {
|
||||||
if (versionId < ProtocolVersions.V_1_19_1_PRE4) {
|
if (versionId < ProtocolVersions.V_1_19_1_PRE4) {
|
||||||
val message = readChatComponent()
|
val message = readChatComponent()
|
||||||
val unsignedContent = if (versionId >= ProtocolVersions.V_22W19A) readOptional { readChatComponent() } else null
|
val unsignedContent = if (versionId >= ProtocolVersions.V_22W19A) readOptional { readChatComponent() } else null
|
||||||
var type = DefaultMessageTypes[readVarInt()]
|
var type = readRegistryItem(connection.registries.messageTypeRegistry)
|
||||||
val sender = readChatMessageSender()
|
val sender = readChatMessageSender()
|
||||||
val sendingTime = readInstant()
|
val sendingTime = readInstant()
|
||||||
val salt = readLong()
|
val salt = readLong()
|
||||||
|
@ -70,6 +70,10 @@ object KUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun minecraft(path: String): ResourceLocation {
|
||||||
|
return ResourceLocation(ProtocolDefinition.DEFAULT_NAMESPACE, path)
|
||||||
|
}
|
||||||
|
|
||||||
fun minosoft(path: String): ResourceLocation {
|
fun minosoft(path: String): ResourceLocation {
|
||||||
return ResourceLocation(ProtocolDefinition.MINOSOFT_NAMESPACE, path)
|
return ResourceLocation(ProtocolDefinition.MINOSOFT_NAMESPACE, path)
|
||||||
}
|
}
|
||||||
|
@ -642,5 +642,33 @@
|
|||||||
"texture": "minecraft:textures/entity/cat/all_black.png"
|
"texture": "minecraft:textures/entity/cat/all_black.png"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"minecraft:message_types": {
|
||||||
|
"0": {
|
||||||
|
"minecraft:chat": {
|
||||||
|
"id": 0,
|
||||||
|
"position": "chat",
|
||||||
|
"chat": {
|
||||||
|
"translation_key": "%s",
|
||||||
|
"parameters": ["content"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"minecraft:system": {
|
||||||
|
"id": 1,
|
||||||
|
"position": "system",
|
||||||
|
"chat": {
|
||||||
|
"translation_key": "%s",
|
||||||
|
"parameters": ["content"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"minecraft:game": {
|
||||||
|
"id": 2,
|
||||||
|
"position": "hotbar",
|
||||||
|
"chat": {
|
||||||
|
"translation_key": "%s",
|
||||||
|
"parameters": ["content"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user