Skip to content

Commit

Permalink
Run cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
neeleshpoli committed Oct 31, 2024
1 parent 813ef02 commit 363e06b
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 13 deletions.
2 changes: 1 addition & 1 deletion pumpkin-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-config/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ impl Default for QueryConfig {
port: None,
}
}
}
}
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
30 changes: 24 additions & 6 deletions pumpkin-protocol/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ impl SBasePacket {
magic,
packet_type: PacketType::Handshake,
session_id: reader.read_i32().await.unwrap(),
payload: SBasePayload::Handshake,
payload: SBasePayload::Handshake,
},
_ => todo!(),
}
}
}

pub struct CBasePacket {
pub packet_type: PacketType,
pub packet_type: PacketType,
pub session_id: i32,
pub payload: CBasePayload,
}
Expand All @@ -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
Expand All @@ -73,7 +73,7 @@ pub enum CBasePayload {
host_port: u16,
host_ip: String,
players: Vec<String>,
}
},
}

impl CBasePacket {
Expand All @@ -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!(),
}
}
}
2 changes: 1 addition & 1 deletion pumpkin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions pumpkin/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -19,7 +21,6 @@ pub async fn start_query_handler() {
let packet = SBasePacket::decode(cursor).await;

println!("{:#?}", packet);

});
}
}

0 comments on commit 363e06b

Please sign in to comment.