diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/protocol/network/connection/play/ConnectionTestUtil.kt b/src/integration-test/kotlin/de/bixilon/minosoft/protocol/network/connection/play/ConnectionTestUtil.kt index 1666e103d..b7c029ded 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/protocol/network/connection/play/ConnectionTestUtil.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/protocol/network/connection/play/ConnectionTestUtil.kt @@ -22,6 +22,7 @@ import de.bixilon.minosoft.config.profile.ProfileTestUtil.createProfiles import de.bixilon.minosoft.data.accounts.types.test.TestAccount import de.bixilon.minosoft.data.entities.entities.player.local.LocalPlayerEntity import de.bixilon.minosoft.data.entities.entities.player.local.SignatureKeyManagement +import de.bixilon.minosoft.data.language.lang.LanguageList import de.bixilon.minosoft.data.registries.registries.Registries import de.bixilon.minosoft.data.world.WorldTestUtil.createWorld import de.bixilon.minosoft.data.world.WorldTestUtil.initialize @@ -47,6 +48,7 @@ object ConnectionTestUtil { fun createConnection(worldSize: Int = 0, light: Boolean = false, version: String? = null): PlayConnection { val connection = IT.OBJENESIS.newInstance(PlayConnection::class.java) + connection::language.forceSet(LanguageList(mutableListOf())) val version = if (version == null) IT.VERSION else Versions[version] ?: throw IllegalArgumentException("Can not find version: $version") connection::sequence.forceSet(AtomicInteger(1)) connection::account.forceSet(TestAccount) diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/protocol/packets/s2c/play/chat/SignedChatMessageS2CPTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/protocol/packets/s2c/play/chat/SignedChatMessageS2CPTest.kt new file mode 100644 index 000000000..13089ad73 --- /dev/null +++ b/src/integration-test/kotlin/de/bixilon/minosoft/protocol/packets/s2c/play/chat/SignedChatMessageS2CPTest.kt @@ -0,0 +1,49 @@ +/* + * Minosoft + * Copyright (C) 2020-2023 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 . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.protocol.packets.s2c.play.chat + +import de.bixilon.kutil.reflection.ReflectionUtil.forceSet +import de.bixilon.kutil.uuid.UUIDUtil.toUUID +import de.bixilon.minosoft.data.chat.ChatTextPositions +import de.bixilon.minosoft.data.chat.sender.UnknownMessageSender +import de.bixilon.minosoft.data.entities.entities.player.tab.TabList +import de.bixilon.minosoft.data.language.lang.LanguageList +import de.bixilon.minosoft.data.registries.chat.ChatMessageType +import de.bixilon.minosoft.data.registries.chat.TypeProperties +import de.bixilon.minosoft.data.registries.identified.Namespaces.minecraft +import de.bixilon.minosoft.protocol.network.connection.play.ConnectionTestUtil.createConnection +import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection +import de.bixilon.minosoft.protocol.packets.s2c.play.PacketReadingTestUtil +import org.testng.Assert.assertEquals +import org.testng.annotations.Test + +@Test(groups = ["packet"]) +class SignedChatMessageS2CPTest { + + private fun connection(): PlayConnection { + val connection = createConnection() + connection::language.forceSet(LanguageList(mutableListOf())) + connection::tabList.forceSet(TabList()) + connection.registries.messageType[0] = ChatMessageType(minecraft("dummy"), TypeProperties("test", emptyList(), emptyMap()), null, ChatTextPositions.CHAT) + + return connection + } + + fun vanilla_23w40a() { + val packet = PacketReadingTestUtil.read("signed_chat_message/vanilla_23w40a", "23w40a", connection(), constructor = ::SignedChatMessageS2CP) + assertEquals(packet.message.message, "abc") + assertEquals(packet.message.sender, UnknownMessageSender("a21a6c65-bbd4-48ca-9d79-e07139e1780d".toUUID())) + } +} + diff --git a/src/integration-test/resources/packets/signed_chat_message/vanilla_23w40a.bin b/src/integration-test/resources/packets/signed_chat_message/vanilla_23w40a.bin new file mode 100644 index 000000000..d0729d879 Binary files /dev/null and b/src/integration-test/resources/packets/signed_chat_message/vanilla_23w40a.bin differ diff --git a/src/main/java/de/bixilon/minosoft/data/chat/type/MessageType.kt b/src/main/java/de/bixilon/minosoft/data/chat/type/MessageType.kt deleted file mode 100644 index 10fe272e2..000000000 --- a/src/main/java/de/bixilon/minosoft/data/chat/type/MessageType.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 . - * - * This software is not affiliated with Mojang AB, the original developer of Minecraft. - */ - -package de.bixilon.minosoft.data.chat.type - -import de.bixilon.minosoft.data.registries.chat.ChatMessageType -import de.bixilon.minosoft.data.text.ChatComponent - -@Deprecated("Refactor") -class MessageType( - val type: ChatMessageType, - val text: ChatComponent, - val targetName: ChatComponent?, -)