Pumpkin/pumpkin-protocol/src/server/config/plugin_message.rs
Alexander Medvedev 3d789f7450 Some Renames
2025-02-05 23:12:16 +01:00

26 lines
676 B
Rust

use bytes::Buf;
use pumpkin_data::packet::serverbound::CONFIG_CUSTOM_PAYLOAD;
use pumpkin_macros::server_packet;
use crate::{
bytebuf::{ByteBuf, ReadingError},
codec::identifier::Identifier,
ServerPacket,
};
const MAX_PAYLOAD_SIZE: usize = 1048576;
#[server_packet(CONFIG_CUSTOM_PAYLOAD)]
pub struct SPluginMessage {
pub channel: Identifier,
pub data: bytes::Bytes,
}
impl ServerPacket for SPluginMessage {
fn read(bytebuf: &mut impl Buf) -> Result<Self, ReadingError> {
Ok(Self {
channel: bytebuf.try_get_identifier()?,
data: bytebuf.try_copy_to_bytes_len(bytebuf.remaining(), MAX_PAYLOAD_SIZE)?,
})
}
}