From 363e06b7aaf95387504adf04edab4ec78ba6cb17 Mon Sep 17 00:00:00 2001 From: "neelesh.poli2006@gmail.com" <72574589+neeleshpoli@users.noreply.github.com> Date: Thu, 31 Oct 2024 07:40:36 -0500 Subject: [PATCH] Run cargo fmt --- pumpkin-config/src/lib.rs | 2 +- pumpkin-config/src/query.rs | 2 +- pumpkin-protocol/src/lib.rs | 2 +- pumpkin-protocol/src/query.rs | 30 ++++++++++++++++++++++++------ pumpkin/src/main.rs | 2 +- pumpkin/src/query.rs | 7 ++++--- 6 files changed, 32 insertions(+), 13 deletions(-) diff --git a/pumpkin-config/src/lib.rs b/pumpkin-config/src/lib.rs index c4bae06f..e7f4f4ee 100644 --- a/pumpkin-config/src/lib.rs +++ b/pumpkin-config/src/lib.rs @@ -17,8 +17,8 @@ use std::{ pub mod auth; pub mod logging; pub mod proxy; -pub mod resource_pack; pub mod query; +pub mod resource_pack; pub use auth::AuthenticationConfig; pub use commands::CommandsConfig; diff --git a/pumpkin-config/src/query.rs b/pumpkin-config/src/query.rs index 65593173..6a735149 100644 --- a/pumpkin-config/src/query.rs +++ b/pumpkin-config/src/query.rs @@ -18,4 +18,4 @@ impl Default for QueryConfig { port: None, } } -} \ No newline at end of file +} diff --git a/pumpkin-protocol/src/lib.rs b/pumpkin-protocol/src/lib.rs index 7b42e96d..d30ae3ba 100644 --- a/pumpkin-protocol/src/lib.rs +++ b/pumpkin-protocol/src/lib.rs @@ -7,9 +7,9 @@ pub mod bytebuf; pub mod client; pub mod packet_decoder; pub mod packet_encoder; +pub mod query; pub mod server; pub mod slot; -pub mod query; mod var_int; pub use var_int::*; diff --git a/pumpkin-protocol/src/query.rs b/pumpkin-protocol/src/query.rs index 581e168b..cd4dcc7a 100644 --- a/pumpkin-protocol/src/query.rs +++ b/pumpkin-protocol/src/query.rs @@ -31,7 +31,7 @@ impl SBasePacket { magic, packet_type: PacketType::Handshake, session_id: reader.read_i32().await.unwrap(), - payload: SBasePayload::Handshake, + payload: SBasePayload::Handshake, }, _ => todo!(), } @@ -39,7 +39,7 @@ impl SBasePacket { } pub struct CBasePacket { - pub packet_type: PacketType, + pub packet_type: PacketType, pub session_id: i32, pub payload: CBasePayload, } @@ -49,7 +49,7 @@ pub enum CBasePayload { // For simplicity use a number type // Should be encoded as string here // Will be converted in encoding - challange_token: i32 + challange_token: i32, }, BasicInfo { // Use CString as protocol requires nul terminated strings @@ -73,7 +73,7 @@ pub enum CBasePayload { host_port: u16, host_ip: String, players: Vec, - } + }, } impl CBasePacket { @@ -82,8 +82,26 @@ impl CBasePacket { match &self.payload { CBasePayload::Handshake { challange_token } => todo!(), - CBasePayload::BasicInfo { motd, gametype, map, num_players, max_players, host_port, host_ip } => todo!(), - CBasePayload::FullInfo { hostname, version, plugins, map, num_players, max_players, host_port, host_ip, players } => todo!(), + CBasePayload::BasicInfo { + motd, + gametype, + map, + num_players, + max_players, + host_port, + host_ip, + } => todo!(), + CBasePayload::FullInfo { + hostname, + version, + plugins, + map, + num_players, + max_players, + host_port, + host_ip, + players, + } => todo!(), } } } diff --git a/pumpkin/src/main.rs b/pumpkin/src/main.rs index c6be951a..41317cd8 100644 --- a/pumpkin/src/main.rs +++ b/pumpkin/src/main.rs @@ -44,10 +44,10 @@ pub mod command; pub mod entity; pub mod error; pub mod proxy; +pub mod query; pub mod rcon; pub mod server; pub mod world; -pub mod query; fn scrub_address(ip: &str) -> String { use pumpkin_config::BASIC_CONFIG; diff --git a/pumpkin/src/query.rs b/pumpkin/src/query.rs index 174a91ad..f9f9604b 100644 --- a/pumpkin/src/query.rs +++ b/pumpkin/src/query.rs @@ -6,11 +6,13 @@ use pumpkin_protocol::query::SBasePacket; use tokio::net::UdpSocket; pub async fn start_query_handler() { - let socket = UdpSocket::bind("0.0.0.0:25565").await.expect("Unable to bind to address"); + let socket = UdpSocket::bind("0.0.0.0:25565") + .await + .expect("Unable to bind to address"); log::info!("Query socket created"); loop { - let mut buf= vec![0; 1024]; + let mut buf = vec![0; 1024]; log::info!("Waiting for requests"); let (len, addr) = socket.recv_from(&mut buf).await.unwrap(); @@ -19,7 +21,6 @@ pub async fn start_query_handler() { let packet = SBasePacket::decode(cursor).await; println!("{:#?}", packet); - }); } }