protocol: add SPluginMessage
This commit is contained in:
1 parent
a548c3ee40
commit
e9b475639a
6 files changed
+45
-7
No files matched your search
@@ -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()
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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>;
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user