Fixed errors from macro conversion
This commit is contained in:
parent
fb2c45d163
commit
6003f6b5ed
|
|
@ -50,7 +50,7 @@ pub fn derive_packet(input: TokenStream) -> TokenStream {
|
||||||
let read_fields = fields.named.iter().map(|f| {
|
let read_fields = fields.named.iter().map(|f| {
|
||||||
let fname = &f.ident;
|
let fname = &f.ident;
|
||||||
let fty = &f.ty;
|
let fty = &f.ty;
|
||||||
quote! { #fname: <#fty as McType>::get(data)? }
|
quote! { #fname: <#fty as mc_types::McType>::get(data)? }
|
||||||
});
|
});
|
||||||
|
|
||||||
let write_fields = fields.named.iter().map(|f| {
|
let write_fields = fields.named.iter().map(|f| {
|
||||||
|
|
@ -63,9 +63,9 @@ pub fn derive_packet(input: TokenStream) -> TokenStream {
|
||||||
|
|
||||||
let expanded = quote! {
|
let expanded = quote! {
|
||||||
impl Packet for #name {
|
impl Packet for #name {
|
||||||
fn packet_id() -> i32 { #packet_id }
|
fn packet_id() -> mc_types::VarInt { mc_types::VarInt(#packet_id) }
|
||||||
|
|
||||||
fn get(data: &mut Vec<u8>) -> Result<Self> {
|
fn get(data: &mut Vec<u8>) -> mc_types::Result<Self> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
#(#read_fields),*
|
#(#read_fields),*
|
||||||
})
|
})
|
||||||
|
|
@ -73,7 +73,7 @@ pub fn derive_packet(input: TokenStream) -> TokenStream {
|
||||||
|
|
||||||
fn convert(&self) -> Vec<u8> {
|
fn convert(&self) -> Vec<u8> {
|
||||||
let mut out = Vec::new();
|
let mut out = Vec::new();
|
||||||
out.extend(convert_var_int(Self::packet_id()));
|
out.extend(mc_types::convert_var_int(Self::packet_id()));
|
||||||
#(#write_fields)*
|
#(#write_fields)*
|
||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|
@ -84,13 +84,13 @@ pub fn derive_packet(input: TokenStream) -> TokenStream {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl #enum_name {
|
impl #enum_name {
|
||||||
pub async fn read<T: ProtocolRead + Send>(conn: &mut T) -> Result<Self> {
|
pub async fn read<T: mc_types::ProtocolRead + Send>(conn: &mut T) -> mc_types::Result<Self> {
|
||||||
let mut data = conn.read_data().await?;
|
let mut data = conn.read_data().await?;
|
||||||
let packet_id = get_var_int(&mut data)?;
|
let packet_id = mc_types::get_var_int(&mut data)?;
|
||||||
if packet_id == #name::packet_id() {
|
if packet_id == #name::packet_id() {
|
||||||
Ok(Self::#enum_variant_ident(#name::get(&mut data)?))
|
Ok(Self::#enum_variant_ident(#name::get(&mut data)?))
|
||||||
} else {
|
} else {
|
||||||
Err(Box::new(PacketError::InvalidPacketId(packet_id)))
|
Err(Box::new(mc_types::PacketError::InvalidPacketId(packet_id)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -119,7 +119,7 @@ pub fn derive_mctype_struct(input: TokenStream) -> TokenStream {
|
||||||
let read_fields = fields.named.iter().map(|f| {
|
let read_fields = fields.named.iter().map(|f| {
|
||||||
let fname = &f.ident;
|
let fname = &f.ident;
|
||||||
let fty = &f.ty;
|
let fty = &f.ty;
|
||||||
quote! { #fname: <#fty as McType>::get(data)? }
|
quote! { #fname: <#fty as mc_types::McType>::get(data)? }
|
||||||
});
|
});
|
||||||
|
|
||||||
let write_fields = fields.named.iter().map(|f| {
|
let write_fields = fields.named.iter().map(|f| {
|
||||||
|
|
@ -128,8 +128,8 @@ pub fn derive_mctype_struct(input: TokenStream) -> TokenStream {
|
||||||
});
|
});
|
||||||
|
|
||||||
let expanded = quote! {
|
let expanded = quote! {
|
||||||
impl McType for #name {
|
impl mc_types::McType for #name {
|
||||||
fn get(data: &mut Vec<u8>) -> Result<Self> {
|
fn get(data: &mut Vec<u8>) -> mc_types::Result<Self> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
#(#read_fields),*
|
#(#read_fields),*
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
pub mod serverbound {
|
pub mod serverbound {
|
||||||
|
|
||||||
use mc_derive::Packet;
|
use purple_cello_mc_derive::Packet;
|
||||||
use crate::mc_types::{self, Result, Packet};
|
use crate::mc_types::{self, Packet, McType};
|
||||||
|
|
||||||
#[derive(Packet)]
|
#[derive(Packet)]
|
||||||
#[packet(id = 0, name = "Handshake")]
|
#[packet(id = 0, name = "Handshake")]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
// Yeahbut September 2025
|
// Yeahbut September 2025
|
||||||
|
|
||||||
use crate::mc_types::{self, Result, Packet};
|
use purple_cello_mc_derive::{Packet, McType};
|
||||||
|
use crate::mc_types::{self, Packet, McType};
|
||||||
|
|
||||||
#[derive(Packet)]
|
#[derive(Packet)]
|
||||||
#[packet(id = 0, name = "Disconnect")]
|
#[packet(id = 0, name = "Disconnect")]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
// Yeahbut September 2025
|
// Yeahbut September 2025
|
||||||
|
|
||||||
use crate::mc_types::{self, Result, Packet};
|
use purple_cello_mc_derive::Packet;
|
||||||
|
use crate::mc_types::{self, Packet, McType};
|
||||||
|
|
||||||
#[derive(Packet)]
|
#[derive(Packet)]
|
||||||
#[packet(id = 0, name = "LoginStart")]
|
#[packet(id = 0, name = "LoginStart")]
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ use serde::{Serialize, Deserialize};
|
||||||
pub use crate::mc_types::error::PacketError;
|
pub use crate::mc_types::error::PacketError;
|
||||||
pub use crate::mc_types::protocol::{ProtocolRead, ProtocolConnection};
|
pub use crate::mc_types::protocol::{ProtocolRead, ProtocolConnection};
|
||||||
pub use crate::mc_types::packet::{Result, Packet};
|
pub use crate::mc_types::packet::{Result, Packet};
|
||||||
|
pub use crate::mc_types::helpers::{convert_var_int, get_var_int};
|
||||||
use crate::mc_types::helpers::*;
|
use crate::mc_types::helpers::*;
|
||||||
|
|
||||||
pub const VERSION_NAME: &str = "1.21";
|
pub const VERSION_NAME: &str = "1.21";
|
||||||
|
|
@ -106,23 +107,23 @@ impl UUID {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl McType for VarInt {
|
impl McType for VarInt {
|
||||||
fn get(data: &mut Vec<u8>) -> Result<Self> { Ok(get_var_int(data)) }
|
fn get(data: &mut Vec<u8>) -> Result<Self> { get_var_int(data) }
|
||||||
fn convert(&self) -> Vec<u8> { convert_var_int(*self) }
|
fn convert(&self) -> Vec<u8> { convert_var_int(*self) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl McType for VarLong {
|
impl McType for VarLong {
|
||||||
fn get(data: &mut Vec<u8>) -> Result<Self> { Ok(get_var_long(data)) }
|
fn get(data: &mut Vec<u8>) -> Result<Self> { get_var_long(data) }
|
||||||
fn convert(&self) -> Vec<u8> { convert_var_long(*self) }
|
fn convert(&self) -> Vec<u8> { convert_var_long(*self) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl McType for String {
|
impl McType for String {
|
||||||
fn get(data: &mut Vec<u8>) -> Result<Self> { Ok(get_string(data)) }
|
fn get(data: &mut Vec<u8>) -> Result<Self> { get_string(data) }
|
||||||
fn convert(&self) -> Vec<u8> { convert_string(*self) }
|
fn convert(&self) -> Vec<u8> { convert_string(self) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: McType> McType for Vec<T> {
|
impl<T: McType> McType for Vec<T> {
|
||||||
fn get(data: &mut Vec<u8>) -> Result<Self> {
|
fn get(data: &mut Vec<u8>) -> Result<Self> {
|
||||||
let length = get_var_int(data)?;
|
let length = get_var_int(data)?.0;
|
||||||
let mut out = Vec::with_capacity(length as usize);
|
let mut out = Vec::with_capacity(length as usize);
|
||||||
for _ in 0..length {
|
for _ in 0..length {
|
||||||
out.push(T::get(data)?);
|
out.push(T::get(data)?);
|
||||||
|
|
@ -131,7 +132,7 @@ impl<T: McType> McType for Vec<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convert(&self) -> Vec<u8> {
|
fn convert(&self) -> Vec<u8> {
|
||||||
let mut data = convert_var_int(self.len() as i32);
|
let mut data = convert_var_int(VarInt(self.len() as i32));
|
||||||
for el in self {
|
for el in self {
|
||||||
data.extend(el.convert());
|
data.extend(el.convert());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,13 @@
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
|
||||||
|
use crate::mc_types::VarInt;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum PacketError {
|
pub enum PacketError {
|
||||||
ValueTooLarge,
|
ValueTooLarge,
|
||||||
RanOutOfBytes,
|
RanOutOfBytes,
|
||||||
InvalidPacketId(i32),
|
InvalidPacketId(VarInt),
|
||||||
InvalidUUIDString,
|
InvalidUUIDString,
|
||||||
EncryptionError,
|
EncryptionError,
|
||||||
}
|
}
|
||||||
|
|
@ -20,7 +22,7 @@ impl fmt::Display for PacketError {
|
||||||
PacketError::RanOutOfBytes =>
|
PacketError::RanOutOfBytes =>
|
||||||
write!(f, "Ran out of bytes while reading VarInt"),
|
write!(f, "Ran out of bytes while reading VarInt"),
|
||||||
PacketError::InvalidPacketId(packet_id) =>
|
PacketError::InvalidPacketId(packet_id) =>
|
||||||
write!(f, "Invalid packet id: {}", packet_id),
|
write!(f, "Invalid packet id: {}", packet_id.0),
|
||||||
PacketError::InvalidUUIDString =>
|
PacketError::InvalidUUIDString =>
|
||||||
write!(f, "Invalid UUID format"),
|
write!(f, "Invalid UUID format"),
|
||||||
PacketError::EncryptionError =>
|
PacketError::EncryptionError =>
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,8 @@ pub fn convert_f64(value: f64) -> Vec<u8> {
|
||||||
convert_u64(value as u64)
|
convert_u64(value as u64)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_uuid(data: &mut Vec<u8>) -> u128 {
|
pub fn get_uuid(data: &mut Vec<u8>) -> UUID {
|
||||||
|
UUID(
|
||||||
((data.remove(0) as u128) << 120) |
|
((data.remove(0) as u128) << 120) |
|
||||||
((data.remove(0) as u128) << 112) |
|
((data.remove(0) as u128) << 112) |
|
||||||
((data.remove(0) as u128) << 104) |
|
((data.remove(0) as u128) << 104) |
|
||||||
|
|
@ -124,28 +125,29 @@ pub fn get_uuid(data: &mut Vec<u8>) -> u128 {
|
||||||
((data.remove(0) as u128) << 16) |
|
((data.remove(0) as u128) << 16) |
|
||||||
((data.remove(0) as u128) << 8) |
|
((data.remove(0) as u128) << 8) |
|
||||||
(data.remove(0) as u128)
|
(data.remove(0) as u128)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
pub fn convert_uuid(value: u128) -> Vec<u8> {
|
pub fn convert_uuid(value: UUID) -> Vec<u8> {
|
||||||
vec![
|
vec![
|
||||||
((value & 0xFF000000000000000000000000000000) >> 120) as u8,
|
((value.0 & 0xFF000000000000000000000000000000) >> 120) as u8,
|
||||||
((value & 0xFF0000000000000000000000000000) >> 112) as u8,
|
((value.0 & 0xFF0000000000000000000000000000) >> 112) as u8,
|
||||||
((value & 0xFF00000000000000000000000000) >> 104) as u8,
|
((value.0 & 0xFF00000000000000000000000000) >> 104) as u8,
|
||||||
((value & 0xFF000000000000000000000000) >> 96) as u8,
|
((value.0 & 0xFF000000000000000000000000) >> 96) as u8,
|
||||||
((value & 0xFF0000000000000000000000) >> 88) as u8,
|
((value.0 & 0xFF0000000000000000000000) >> 88) as u8,
|
||||||
((value & 0xFF00000000000000000000) >> 80) as u8,
|
((value.0 & 0xFF00000000000000000000) >> 80) as u8,
|
||||||
((value & 0xFF000000000000000000) >> 72) as u8,
|
((value.0 & 0xFF000000000000000000) >> 72) as u8,
|
||||||
((value & 0xFF0000000000000000) >> 64) as u8,
|
((value.0 & 0xFF0000000000000000) >> 64) as u8,
|
||||||
((value & 0xFF00000000000000) >> 56) as u8,
|
((value.0 & 0xFF00000000000000) >> 56) as u8,
|
||||||
((value & 0xFF000000000000) >> 48) as u8,
|
((value.0 & 0xFF000000000000) >> 48) as u8,
|
||||||
((value & 0xFF0000000000) >> 40) as u8,
|
((value.0 & 0xFF0000000000) >> 40) as u8,
|
||||||
((value & 0xFF00000000) >> 32) as u8,
|
((value.0 & 0xFF00000000) >> 32) as u8,
|
||||||
((value & 0xFF000000) >> 24) as u8,
|
((value.0 & 0xFF000000) >> 24) as u8,
|
||||||
((value & 0xFF0000) >> 16) as u8,
|
((value.0 & 0xFF0000) >> 16) as u8,
|
||||||
((value & 0xFF00) >> 8) as u8,
|
((value.0 & 0xFF00) >> 8) as u8,
|
||||||
(value & 0xFF) as u8,
|
( value.0 & 0xFF) as u8,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
pub fn uuid_u128_to_string(uuid: u128) -> String {
|
pub fn uuid_u128_to_string(uuid: UUID) -> String {
|
||||||
let uuid_bytes = convert_uuid(uuid);
|
let uuid_bytes = convert_uuid(uuid);
|
||||||
format!(
|
format!(
|
||||||
"{:08x}-{:04x}-{:04x}-{:04x}-{:012x}",
|
"{:08x}-{:04x}-{:04x}-{:04x}-{:012x}",
|
||||||
|
|
@ -170,26 +172,26 @@ pub fn uuid_u128_to_string(uuid: u128) -> String {
|
||||||
]),
|
]),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
pub fn uuid_string_to_u128(uuid: &str) -> Result<u128> {
|
pub fn uuid_string_to_u128(uuid: &str) -> Result<UUID> {
|
||||||
let cleaned_uuid = uuid.replace("-", "");
|
let cleaned_uuid = uuid.replace("-", "");
|
||||||
if cleaned_uuid.len() != 32 {
|
if cleaned_uuid.len() != 32 {
|
||||||
return Err(Box::new(PacketError::InvalidUUIDString));
|
return Err(Box::new(PacketError::InvalidUUIDString));
|
||||||
}
|
}
|
||||||
Ok(u128::from_str_radix(&cleaned_uuid, 16)?)
|
Ok(UUID(u128::from_str_radix(&cleaned_uuid, 16)?))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_var_int(data: &mut Vec<u8>) -> Result<i32> {
|
pub fn get_var_int(data: &mut Vec<u8>) -> Result<VarInt> {
|
||||||
Ok(get_var(data, 32)? as i32)
|
Ok(VarInt(get_var(data, 32)? as i32))
|
||||||
}
|
}
|
||||||
pub fn convert_var_int(value: i32) -> Vec<u8> {
|
pub fn convert_var_int(value: VarInt) -> Vec<u8> {
|
||||||
convert_var(value as i64)
|
convert_var(value.0 as i64)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_var_long(data: &mut Vec<u8>) -> Result<i64> {
|
pub fn get_var_long(data: &mut Vec<u8>) -> Result<VarLong> {
|
||||||
get_var(data, 64)
|
Ok(VarLong(get_var(data, 32)?))
|
||||||
}
|
}
|
||||||
pub fn convert_var_long(value: i64) -> Vec<u8> {
|
pub fn convert_var_long(value: VarLong) -> Vec<u8> {
|
||||||
convert_var(value)
|
convert_var(value.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_var(data: &mut Vec<u8>, size: u8) -> Result<i64> {
|
fn get_var(data: &mut Vec<u8>, size: u8) -> Result<i64> {
|
||||||
|
|
@ -231,13 +233,13 @@ fn convert_var(mut value: i64) -> Vec<u8> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_string(data: &mut Vec<u8>) -> Result<String> {
|
pub fn get_string(data: &mut Vec<u8>) -> Result<String> {
|
||||||
let length = get_var_int(data)? as usize;
|
let length = get_var_int(data)?.0 as usize;
|
||||||
let buffer = data[..length].to_vec();
|
let buffer = data[..length].to_vec();
|
||||||
for _ in 0..length { data.remove(0); }
|
for _ in 0..length { data.remove(0); }
|
||||||
Ok(String::from_utf8_lossy(&buffer).to_string())
|
Ok(String::from_utf8_lossy(&buffer).to_string())
|
||||||
}
|
}
|
||||||
pub fn convert_string(s: &str) -> Vec<u8> {
|
pub fn convert_string(s: &str) -> Vec<u8> {
|
||||||
let length = s.len() as i32;
|
let length = VarInt(s.len() as i32);
|
||||||
let mut data = convert_var_int(length);
|
let mut data = convert_var_int(length);
|
||||||
data.append(&mut s.as_bytes().to_vec());
|
data.append(&mut s.as_bytes().to_vec());
|
||||||
data
|
data
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ pub type Result<T> = std::result::Result<T, Box<dyn Error>>;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait Packet: Sized {
|
pub trait Packet: Sized {
|
||||||
fn packet_id() -> i32;
|
fn packet_id() -> VarInt;
|
||||||
fn get(data: &mut Vec<u8>) -> Result<Self>;
|
fn get(data: &mut Vec<u8>) -> Result<Self>;
|
||||||
fn convert(&self) -> Vec<u8>;
|
fn convert(&self) -> Vec<u8>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -217,7 +217,7 @@ impl<'a> ProtocolRead for ProtocolConnection<'a> {
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> ProtocolWrite for ProtocolConnection<'a> {
|
impl<'a> ProtocolWrite for ProtocolConnection<'a> {
|
||||||
async fn write_data(&mut self, data: &mut Vec<u8>) -> Result<()> {
|
async fn write_data(&mut self, data: &mut Vec<u8>) -> Result<()> {
|
||||||
let mut out_data = convert_var_int(data.len() as i32);
|
let mut out_data = convert_var_int(VarInt(data.len() as i32));
|
||||||
out_data.append(data);
|
out_data.append(data);
|
||||||
match &mut self.aes_cipher {
|
match &mut self.aes_cipher {
|
||||||
Some(aes_cipher) => {
|
Some(aes_cipher) => {
|
||||||
|
|
@ -256,7 +256,7 @@ unsafe impl<'a> Send for WriteHaftProtocolConnection<'a> {}
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<'a> ProtocolWrite for WriteHaftProtocolConnection<'a> {
|
impl<'a> ProtocolWrite for WriteHaftProtocolConnection<'a> {
|
||||||
async fn write_data(&mut self, data: &mut Vec<u8>) -> Result<()> {
|
async fn write_data(&mut self, data: &mut Vec<u8>) -> Result<()> {
|
||||||
let mut out_data = convert_var_int(data.len() as i32);
|
let mut out_data = convert_var_int(VarInt(data.len() as i32));
|
||||||
out_data.append(data);
|
out_data.append(data);
|
||||||
match &mut self.aes_cipher {
|
match &mut self.aes_cipher {
|
||||||
Some(aes_cipher) => {
|
Some(aes_cipher) => {
|
||||||
|
|
@ -342,7 +342,7 @@ async fn read_var_int_stream(stream: &mut OwnedReadHalf) -> Result<i32> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let varint = get_var_int(&mut data)?;
|
let varint = get_var_int(&mut data)?.0;
|
||||||
|
|
||||||
Ok(varint)
|
Ok(varint)
|
||||||
}
|
}
|
||||||
|
|
@ -363,7 +363,7 @@ async fn read_var_int_stream_encrypted(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let varint = get_var_int(&mut data)?;
|
let varint = get_var_int(&mut data)?.0;
|
||||||
|
|
||||||
Ok(varint)
|
Ok(varint)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ pub struct PlayPacket {
|
||||||
|
|
||||||
impl Packet for PlayPacket {
|
impl Packet for PlayPacket {
|
||||||
|
|
||||||
fn packet_id() -> i32 {0}
|
fn packet_id() -> mc_types::VarInt {mc_types::VarInt(0)}
|
||||||
|
|
||||||
fn get(data: &mut Vec<u8>) -> Result<Self> {
|
fn get(data: &mut Vec<u8>) -> Result<Self> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,8 @@ use serde::{Serialize, Deserialize, Serializer, Deserializer};
|
||||||
use serde::de::{self, Visitor, MapAccess};
|
use serde::de::{self, Visitor, MapAccess};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use crate::mc_types::{self, Result, Packet, PacketError};
|
use purple_cello_mc_derive::Packet;
|
||||||
|
use crate::mc_types::{self, Packet, McType};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct StatusVersion {
|
pub struct StatusVersion {
|
||||||
|
|
@ -106,13 +107,13 @@ pub struct Status {
|
||||||
|
|
||||||
impl Status {
|
impl Status {
|
||||||
|
|
||||||
pub fn from_json(data: StatusResponseData) -> Result<Self> {
|
pub fn from_json(data: StatusResponseData) -> mc_types::Result<Self> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
response: serde_json::to_string(&data)?
|
response: serde_json::to_string(&data)?
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_json(&self) -> Result<StatusResponseData> {
|
pub fn get_json(&self) -> mc_types::Result<StatusResponseData> {
|
||||||
Ok(serde_json::from_str(&self.response)?)
|
Ok(serde_json::from_str(&self.response)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
// Yeahbut September 2025
|
// Yeahbut September 2025
|
||||||
|
|
||||||
use crate::mc_types::{self, Result, Packet};
|
use purple_cello_mc_derive::Packet;
|
||||||
|
use crate::mc_types::{self, Packet, McType};
|
||||||
|
|
||||||
#[derive(Packet)]
|
#[derive(Packet)]
|
||||||
#[packet(id = 0, name = "Status")]
|
#[packet(id = 0, name = "Status")]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue