From 9642558f8f8d983a7087f15d68be8cf07a85f0c2 Mon Sep 17 00:00:00 2001 From: mat Date: Wed, 15 Dec 2021 23:10:55 -0600 Subject: azalea --- .../packets/handshake/client_intention_packet.rs | 36 ---------------- minecraft-protocol/src/packets/handshake/mod.rs | 49 ---------------------- 2 files changed, 85 deletions(-) delete mode 100644 minecraft-protocol/src/packets/handshake/client_intention_packet.rs delete mode 100644 minecraft-protocol/src/packets/handshake/mod.rs (limited to 'minecraft-protocol/src/packets/handshake') diff --git a/minecraft-protocol/src/packets/handshake/client_intention_packet.rs b/minecraft-protocol/src/packets/handshake/client_intention_packet.rs deleted file mode 100644 index 868626b3..00000000 --- a/minecraft-protocol/src/packets/handshake/client_intention_packet.rs +++ /dev/null @@ -1,36 +0,0 @@ -use std::hash::Hash; - -use tokio::io::BufReader; - -use crate::{mc_buf::Writable, packets::ConnectionProtocol}; - -use super::HandshakePacket; - -#[derive(Hash, Clone, Debug)] -pub struct ClientIntentionPacket { - pub protocol_version: u32, - pub hostname: String, - pub port: u16, - /// 1 for status, 2 for login - pub intention: ConnectionProtocol, -} - -impl ClientIntentionPacket { - pub fn get(self) -> HandshakePacket { - HandshakePacket::ClientIntentionPacket(self) - } - - pub fn write(&self, buf: &mut Vec) { - buf.write_varint(self.protocol_version as i32).unwrap(); - buf.write_utf(&self.hostname).unwrap(); - buf.write_short(self.port).unwrap(); - buf.write_varint(self.intention.clone() as i32).unwrap(); - } - - pub async fn read( - _buf: &mut BufReader, - ) -> Result { - Err("ClientIntentionPacket::parse not implemented".to_string()) - // Ok(ClientIntentionPacket {}.get()) - } -} diff --git a/minecraft-protocol/src/packets/handshake/mod.rs b/minecraft-protocol/src/packets/handshake/mod.rs deleted file mode 100644 index 01010e1e..00000000 --- a/minecraft-protocol/src/packets/handshake/mod.rs +++ /dev/null @@ -1,49 +0,0 @@ -pub mod client_intention_packet; - -use async_trait::async_trait; -use tokio::io::BufReader; - -use crate::connect::PacketFlow; - -use super::ProtocolPacket; - -#[derive(Clone, Debug)] -pub enum HandshakePacket -where - Self: Sized, -{ - ClientIntentionPacket(client_intention_packet::ClientIntentionPacket), -} - -#[async_trait] -impl ProtocolPacket for HandshakePacket { - fn id(&self) -> u32 { - match self { - HandshakePacket::ClientIntentionPacket(_packet) => 0x00, - } - } - - fn write(&self, buf: &mut Vec) { - match self { - HandshakePacket::ClientIntentionPacket(packet) => packet.write(buf), - } - } - - /// Read a packet by its id, ConnectionProtocol, and flow - async fn read( - id: u32, - flow: &PacketFlow, - buf: &mut BufReader, - ) -> Result - where - Self: Sized, - { - match flow { - PacketFlow::ServerToClient => Err("HandshakePacket::read not implemented".to_string()), - PacketFlow::ClientToServer => match id { - 0x00 => Ok(client_intention_packet::ClientIntentionPacket::read(buf).await?), - _ => Err(format!("Unknown ClientToServer status packet id: {}", id)), - }, - } - } -} -- cgit v1.2.3