1.19.1-pre4: wip message reading

This commit is contained in:
Bixilon 2022-07-19 00:14:48 +02:00
parent 7b5ad38113
commit 1fc08c0662
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
11 changed files with 190 additions and 1 deletions

View File

@ -0,0 +1,20 @@
/*
* 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.chat.message
import de.bixilon.minosoft.data.text.ChatComponent
interface ChatMessage {
val text: ChatComponent
}

View File

@ -0,0 +1,24 @@
/*
* 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.chat.message
import de.bixilon.minosoft.data.chat.ChatMessageTypes
import de.bixilon.minosoft.data.text.ChatComponent
import java.util.*
open class PlayerChatMessage(
text: ChatComponent,
type: ChatMessageTypes,
val sender: UUID,
) : SimpleChatMessage(text, type)

View File

@ -0,0 +1,22 @@
/*
* 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.chat.message
import de.bixilon.minosoft.data.chat.ChatMessageTypes
import de.bixilon.minosoft.data.text.ChatComponent
open class SimpleChatMessage(
override val text: ChatComponent,
val type: ChatMessageTypes,
) : ChatMessage

View File

@ -0,0 +1,21 @@
/*
* 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.chat.signature
import java.util.*
class LastSeenMessage(
val profile: UUID,
val signature: ByteArray,
)

View File

@ -0,0 +1,24 @@
/*
* 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.chat.signature
import de.bixilon.minosoft.data.text.ChatComponent
import java.time.Instant
class MessageBody(
val text: ChatComponent,
val time: Instant,
val salt: Long,
val lastSeen: Array<LastSeenMessage>,
)

View File

@ -0,0 +1,21 @@
/*
* 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.chat.signature
import java.util.*
class MessageHeader(
val signature: ByteArray?,
val sender: UUID,
)

View File

@ -0,0 +1,23 @@
/*
* 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.chat.signature
import de.bixilon.minosoft.data.text.ChatComponent
data class SignedMessage(
val header: MessageHeader,
val signature: ByteArray,
val body: MessageBody,
val unsigned: ChatComponent? = null,
)

View File

@ -37,6 +37,7 @@ class ChatMessageS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
private set
init {
val text = buffer.readChatComponent()
if (buffer.versionId >= ProtocolVersions.V_14W04A) {
if (buffer.versionId >= ProtocolVersions.V_1_19_1_PRE2) {
overlay = buffer.readBoolean()

View File

@ -22,6 +22,10 @@ import de.bixilon.minosoft.commands.nodes.builder.CommandNodeBuilder
import de.bixilon.minosoft.commands.parser.factory.ArgumentParserFactories
import de.bixilon.minosoft.commands.parser.minosoft.dummy.DummyParser
import de.bixilon.minosoft.commands.suggestion.factory.SuggestionFactories
import de.bixilon.minosoft.data.chat.signature.LastSeenMessage
import de.bixilon.minosoft.data.chat.signature.MessageBody
import de.bixilon.minosoft.data.chat.signature.MessageHeader
import de.bixilon.minosoft.data.chat.signature.SignedMessage
import de.bixilon.minosoft.data.container.ItemStackUtil
import de.bixilon.minosoft.data.container.stack.ItemStack
import de.bixilon.minosoft.data.entities.entities.player.properties.PlayerProperties
@ -355,4 +359,25 @@ class PlayInByteBuffer : InByteBuffer {
fun <T : Enum<*>> readEnum(registry: EnumRegistry<T>): T? {
return registry[readVarInt()]
}
fun readMessageHeader(): MessageHeader {
return MessageHeader(readOptional { readByteArray() }, readUUID())
}
fun readLastSeenMessage(): LastSeenMessage {
return LastSeenMessage(readUUID(), readByteArray())
}
fun readMessageBody(): MessageBody {
return MessageBody(
text = readChatComponent(),
time = readInstant(),
salt = readLong(),
lastSeen = readArray { readLastSeenMessage() }
)
}
fun readSignedMessage(): SignedMessage {
return SignedMessage(readMessageHeader(), readByteArray(), readMessageBody(), readOptional { readChatComponent() })
}
}

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,12 @@
{
"854": {
"name": "1.19.1-pre4",
"protocol_id": 1073741921,
"packets": {
"c2s": ["confirm_teleport", "block_nbt", "difficulty", "command", "signed_chat_message", "chat_preview", "client_action", "settings", "command_suggestions", "container_button", "container_click", "close_container", "plugin", "book", "entity_nbt", "entity_interact", "generate_structure", "heartbeat", "lock_difficulty", "position", "position_rotation", "rotation", "ground_change", "move_vehicle", "steer_boat", "item_pick", "crafting_recipe", "toggle_fly", "player_action", "entity_action", "steer_vehicle", "pong", "displayed_recipe", "recipe_book", "anvil_item_name", "resourcepack", "advancement_tab", "trade", "beacon_effect", "hotbar_slot", "command_block", "minecart_command_block", "item_stack_create", "jigsaw_block", "structure_block", "sign_text", "swing_arm", "entity_spectate", "block_interact", "use_item"],
"s2c": ["entity_object_spawn", "entity_experience_orb", "entity_player", "entity_animation", "statistics", "block_break", "block_break_animation", "block_data", "block_action", "block", "bossbar", "difficulty", "chat_preview", "clear_title", "command_suggestions", "commands", "close_container", "container_items", "container_properties", "container_item", "item_cooldown", "chat_suggestions", "plugin", "named_sound", "hide_message","kick", "entity_status", "explosion", "unload_chunk", "game_event", "open_horse_container", "initialize_world_border", "heartbeat", "chunk", "world_event", "particle", "chunk_light", "initialize", "map", "villager_trades", "relative_move", "movement_rotation", "rotation", "move_vehicle", "book", "open_container", "sign_editor", "ping", "crafting_recipe", "player_abilities", "signed_chat_message", "message_header","end_combat_event", "enter_combat_event", "kill_combat_event", "tab_list", "player_face", "position_rotation", "unlock_recipes", "entity_destroy", "entity_remove_effect", "resourcepack", "respawn", "head_rotation", "blocks", "advancement_tab", "play_status", "hotbar_text", "center_world_border", "interpolate_world_border", "size_world_border", "warn_time_world_border", "warn_blocks_world_border", "camera", "hotbar_slot", "chunk_center", "view_distance", "compass_position", "temporary_chat_preview", "objective_position", "entity_data", "entity_attach", "velocity", "entity_equipment", "experience", "health", "objective", "entity_passenger", "teams", "scoreboard_score", "simulation_distance", "subtitle", "time", "title_text", "title_times", "entity_sound", "sound_event", "stop_sound", "chat_message", "tab_list_text", "nbt_response", "entity_collect", "teleport", "advancements", "entity_attributes", "entity_effect", "recipes", "tags"]
}
},
"853": {
"name": "1.19.1-pre3",
"protocol_id": 1073741920,