protocol: add SPluginMessage

This commit is contained in:
Snowiiii committed 2024-08-02 12:31:44 +02:00
1 parent a548c3ee40
commit e9b475639a
6 files changed
+45 -7

No files matched your search

+4
View File
@@ -280,4 +280,8 @@ impl ByteBuffer {
pub fn put_slice(&mut self, src: &[u8]) {
self.buffer.put_slice(src)
}
pub fn get_slice(&mut self) -> BytesMut {
self.buffer.split()
}
}
+2
View File
@@ -14,6 +14,8 @@ pub mod packet_encoder;
pub const MAX_PACKET_SIZE: i32 = 2097152;
/// usally uses a namespace like "minecraft:thing"
pub type Identifier = String;
pub type VarInt = i32;
pub type VarLong = i64;
+1 -4
View File
@@ -3,10 +3,7 @@ use std::io::Write;
use aes::cipher::{generic_array::GenericArray, BlockEncryptMut, BlockSizeUser, KeyIvInit};
use bytes::{BufMut, BytesMut};
use crate::{
bytebuf::ByteBuffer, ClientPacket, PacketError, VarInt32,
MAX_PACKET_SIZE,
};
use crate::{bytebuf::ByteBuffer, ClientPacket, PacketError, VarInt32, MAX_PACKET_SIZE};
type Cipher = cfb8::Encryptor<aes::Aes128>;
+17 -1
View File
@@ -1,4 +1,4 @@
use crate::{bytebuf::ByteBuffer, ServerPacket, VarInt};
use crate::{bytebuf::ByteBuffer, Identifier, ServerPacket, VarInt};
pub struct SClientInformation {
pub locale: String, // 16
@@ -28,6 +28,22 @@ impl ServerPacket for SClientInformation {
}
}
pub struct SPluginMessage {
pub channel: Identifier,
pub data: Vec<u8>,
}
impl ServerPacket for SPluginMessage {
const PACKET_ID: VarInt = 0x02;
fn read(bytebuf: &mut ByteBuffer) -> Self {
Self {
channel: bytebuf.get_string().unwrap(),
data: bytebuf.get_slice().to_vec(),
}
}
}
pub struct SAcknowledgeFinishConfig {}
impl ServerPacket for SAcknowledgeFinishConfig {