mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-14 18:05:51 -04:00
network: 1.19.1-pre5
This commit is contained in:
parent
80027e3754
commit
5e9dd15f0b
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger and contributors
|
||||
*
|
||||
* 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
|
||||
|
||||
class Acknowledgement(
|
||||
val lastSeen: LastSeenMessageList,
|
||||
val lastReceived: LastSeenMessage? = null,
|
||||
) {
|
||||
companion object {
|
||||
val EMPTY = Acknowledgement(LastSeenMessageList(emptyArray()), null)
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger and contributors
|
||||
*
|
||||
* 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
|
||||
|
||||
class LastSeenMessageList(
|
||||
val messages: Array<LastSeenMessage>,
|
||||
)
|
@ -29,7 +29,7 @@ import java.util.*
|
||||
class MessageChain {
|
||||
private var previous: ByteArray? = null
|
||||
|
||||
fun signMessage(version: Version, privateKey: PrivateKey, message: String, preview: ChatComponent?, salt: Long, sender: UUID, time: Instant): ByteArray {
|
||||
fun signMessage(version: Version, privateKey: PrivateKey, message: String, preview: ChatComponent?, salt: Long, sender: UUID, time: Instant, lastSeen: LastSeenMessageList): ByteArray {
|
||||
val signature = CryptManager.createSignature(version)
|
||||
|
||||
signature.initSign(privateKey)
|
||||
@ -45,8 +45,18 @@ class MessageChain {
|
||||
buffer.writeLong(salt)
|
||||
buffer.writeLong(time.epochSecond)
|
||||
buffer.writeBareByteArray(message.getSignatureBytes())
|
||||
// TODo: lastseen
|
||||
|
||||
if (version.versionId >= ProtocolVersions.V_1_19_1_PRE5) {
|
||||
buffer.writeByte(0x46)
|
||||
// ToDo: send preview text (optional)
|
||||
for (entry in lastSeen.messages) {
|
||||
buffer.writeByte(0x46)
|
||||
buffer.writeUUID(entry.profile)
|
||||
buffer.writeBareByteArray(entry.signature)
|
||||
}
|
||||
}
|
||||
val hash = Hashing.sha256().hashBytes(buffer.toArray()).asBytes()
|
||||
|
||||
previous?.let { signature.update(it) }
|
||||
signature.update(Longs.toByteArray(sender.mostSignificantBits))
|
||||
signature.update(Longs.toByteArray(sender.leastSignificantBits))
|
||||
|
@ -16,6 +16,7 @@ package de.bixilon.minosoft.protocol.network.connection.play
|
||||
import de.bixilon.kotlinglm.vec3.Vec3d
|
||||
import de.bixilon.kutil.string.WhitespaceUtil.trimWhitespaces
|
||||
import de.bixilon.minosoft.commands.stack.CommandStack
|
||||
import de.bixilon.minosoft.data.chat.signature.Acknowledgement
|
||||
import de.bixilon.minosoft.data.chat.signature.MessageChain
|
||||
import de.bixilon.minosoft.data.text.BaseComponent
|
||||
import de.bixilon.minosoft.data.text.ChatComponent
|
||||
@ -83,9 +84,11 @@ class ConnectionUtil(
|
||||
val time = Instant.now()
|
||||
val uuid = connection.player.uuid
|
||||
|
||||
val signature = chain.signMessage(connection.version, privateKey, message, null, salt, uuid, time)
|
||||
val acknowledgement = Acknowledgement.EMPTY
|
||||
|
||||
connection.sendPacket(SignedChatMessageC2SP(message.encodeNetwork(), time = time, salt = salt, signature = SignatureData(signature), false))
|
||||
val signature = chain.signMessage(connection.version, privateKey, message, null, salt, uuid, time, acknowledgement.lastSeen)
|
||||
|
||||
connection.sendPacket(SignedChatMessageC2SP(message.encodeNetwork(), time = time, salt = salt, signature = SignatureData(signature), false, acknowledgement))
|
||||
}
|
||||
|
||||
@Deprecated("message will re removed as soon as brigadier is fully implemented")
|
||||
|
@ -12,6 +12,7 @@
|
||||
*/
|
||||
package de.bixilon.minosoft.protocol.packets.c2s.play.chat
|
||||
|
||||
import de.bixilon.minosoft.data.chat.signature.Acknowledgement
|
||||
import de.bixilon.minosoft.protocol.packets.c2s.PlayC2SPacket
|
||||
import de.bixilon.minosoft.protocol.packets.factory.LoadPacket
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayOutByteBuffer
|
||||
@ -28,6 +29,7 @@ class CommandC2SP(
|
||||
val salt: Long,
|
||||
val signature: CommandArgumentSignature,
|
||||
val signedPreview: Boolean,
|
||||
val acknowledgement: Acknowledgement?,
|
||||
) : PlayC2SPacket {
|
||||
|
||||
override fun write(buffer: PlayOutByteBuffer) {
|
||||
@ -42,6 +44,9 @@ class CommandC2SP(
|
||||
if (buffer.versionId >= ProtocolVersions.V_1_19_PRE1) {
|
||||
buffer.writeBoolean(signedPreview)
|
||||
}
|
||||
if (buffer.versionId >= ProtocolVersions.V_1_19_1_PRE5) {
|
||||
buffer.writeAcknowledgement(acknowledgement!!)
|
||||
}
|
||||
}
|
||||
|
||||
override fun log(reducedLog: Boolean) {
|
||||
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.protocol.packets.c2s.play.chat
|
||||
|
||||
import de.bixilon.minosoft.data.chat.signature.Acknowledgement
|
||||
import de.bixilon.minosoft.protocol.packets.c2s.PlayC2SPacket
|
||||
import de.bixilon.minosoft.protocol.packets.factory.LoadPacket
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayOutByteBuffer
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
|
||||
@LoadPacket(threadSafe = false)
|
||||
class MessageAcknowledgementC2SP(
|
||||
val acknowledgement: Acknowledgement,
|
||||
) : PlayC2SPacket {
|
||||
|
||||
override fun write(buffer: PlayOutByteBuffer) {
|
||||
buffer.writeAcknowledgement(acknowledgement)
|
||||
}
|
||||
|
||||
override fun log(reducedLog: Boolean) {
|
||||
Log.log(LogMessageType.NETWORK_PACKETS_OUT, LogLevels.VERBOSE) { "Message acknowledgement (acknowledgement=$acknowledgement)" }
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@
|
||||
*/
|
||||
package de.bixilon.minosoft.protocol.packets.c2s.play.chat
|
||||
|
||||
import de.bixilon.minosoft.data.chat.signature.Acknowledgement
|
||||
import de.bixilon.minosoft.protocol.packets.c2s.PlayC2SPacket
|
||||
import de.bixilon.minosoft.protocol.packets.factory.LoadPacket
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayOutByteBuffer
|
||||
@ -29,6 +30,7 @@ class SignedChatMessageC2SP(
|
||||
val salt: Long,
|
||||
val signature: SignatureData? = null,
|
||||
val previewed: Boolean = false,
|
||||
val acknowledgement: Acknowledgement?,
|
||||
) : PlayC2SPacket {
|
||||
|
||||
override fun write(buffer: PlayOutByteBuffer) {
|
||||
@ -44,6 +46,9 @@ class SignedChatMessageC2SP(
|
||||
if (buffer.versionId >= ProtocolVersions.V_22W19A) {
|
||||
buffer.writeBoolean(previewed)
|
||||
}
|
||||
if (buffer.versionId >= ProtocolVersions.V_1_19_1_PRE5) {
|
||||
buffer.writeAcknowledgement(acknowledgement!!)
|
||||
}
|
||||
}
|
||||
|
||||
override fun log(reducedLog: Boolean) {
|
||||
|
@ -22,10 +22,7 @@ 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.chat.signature.*
|
||||
import de.bixilon.minosoft.data.chat.type.DefaultMessageTypes
|
||||
import de.bixilon.minosoft.data.chat.type.MessageType
|
||||
import de.bixilon.minosoft.data.container.ItemStackUtil
|
||||
@ -372,8 +369,12 @@ class PlayInByteBuffer : InByteBuffer {
|
||||
}
|
||||
|
||||
fun readMessageBody(): MessageBody {
|
||||
val text: ChatComponent = readChatComponent()
|
||||
if (versionId >= ProtocolVersions.V_1_19_1_PRE5) {
|
||||
readOptional { readChatComponent() } // decorated content
|
||||
}
|
||||
return MessageBody(
|
||||
text = readChatComponent(),
|
||||
text = text,
|
||||
time = readInstant(),
|
||||
salt = readLong(),
|
||||
lastSeen = readArray { readLastSeenMessage() }
|
||||
|
@ -13,6 +13,9 @@
|
||||
package de.bixilon.minosoft.protocol.protocol
|
||||
|
||||
import de.bixilon.kotlinglm.vec3.Vec3i
|
||||
import de.bixilon.minosoft.data.chat.signature.Acknowledgement
|
||||
import de.bixilon.minosoft.data.chat.signature.LastSeenMessage
|
||||
import de.bixilon.minosoft.data.chat.signature.LastSeenMessageList
|
||||
import de.bixilon.minosoft.data.container.stack.ItemStack
|
||||
import de.bixilon.minosoft.protocol.PlayerPublicKey
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
@ -97,4 +100,18 @@ class PlayOutByteBuffer(val connection: PlayConnection) : OutByteBuffer() {
|
||||
writeLong(instant.epochSecond)
|
||||
}
|
||||
}
|
||||
|
||||
fun writeLastSeenMessage(lastSeenMessage: LastSeenMessage) {
|
||||
writeUUID(lastSeenMessage.profile)
|
||||
writeByteArray(lastSeenMessage.signature)
|
||||
}
|
||||
|
||||
fun writeLastSeenMessageList(list: LastSeenMessageList) {
|
||||
writeArray(list.messages) { writeLastSeenMessage(it) }
|
||||
}
|
||||
|
||||
fun writeAcknowledgement(acknowledgement: Acknowledgement) {
|
||||
writeLastSeenMessageList(acknowledgement.lastSeen)
|
||||
writeOptional(acknowledgement.lastReceived) { writeLastSeenMessage(it) }
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ package de.bixilon.minosoft.protocol.protocol
|
||||
|
||||
@Suppress("UNUSED")
|
||||
object ProtocolVersions {
|
||||
const val V_1_19_1_PRE5 = 855
|
||||
const val V_1_19_1_PRE4 = 854
|
||||
const val V_1_19_1_PRE3 = 853
|
||||
const val V_1_19_1_PRE2 = 852
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,10 +1,18 @@
|
||||
{
|
||||
"855": {
|
||||
"name": "1.19.1-pre5",
|
||||
"protocol_id": 1073741922,
|
||||
"packets": {
|
||||
"c2s": ["confirm_teleport", "block_nbt", "difficulty", "message_acknowledgement", "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", "message_header", "signed_chat_message", "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"]
|
||||
}
|
||||
},
|
||||
"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"]
|
||||
"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": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user