From 562ab9dbc41e47cc7208041329040b8c82ab41fe Mon Sep 17 00:00:00 2001 From: ice_iix Date: Sun, 30 Sep 2018 00:25:07 -0700 Subject: [PATCH] Remove unused username field in Server. Closes https://github.com/iceiix/steven/issues/1 --- src/server/mod.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index 3e381ab..14a6233 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -37,7 +37,6 @@ pub mod plugin_messages; pub mod target; pub struct Server { - username: String, uuid: protocol::UUID, conn: Option, read_queue: Option>>, @@ -138,7 +137,7 @@ impl Server { read.state = protocol::State::Play; write.state = protocol::State::Play; let rx = Self::spawn_reader(read); - return Ok(Server::new(val.username, protocol::UUID::from_str(&val.uuid), resources, Some(write), Some(rx))); + return Ok(Server::new(protocol::UUID::from_str(&val.uuid), resources, Some(write), Some(rx))); } protocol::packet::Packet::LoginDisconnect(val) => return Err(protocol::Error::Disconnect(val.reason)), val => return Err(protocol::Error::Err(format!("Wrong packet: {:?}", val))), @@ -165,7 +164,6 @@ impl Server { read.enable_encyption(&shared, true); write.enable_encyption(&shared, false); - let username; let uuid; loop { match try!(read.read_packet()) { @@ -175,7 +173,6 @@ impl Server { } protocol::packet::Packet::LoginSuccess(val) => { debug!("Login: {} {}", val.username, val.uuid); - username = val.username; uuid = val.uuid; read.state = protocol::State::Play; write.state = protocol::State::Play; @@ -188,7 +185,7 @@ impl Server { let rx = Self::spawn_reader(read); - Ok(Server::new(username, protocol::UUID::from_str(&uuid), resources, Some(write), Some(rx))) + Ok(Server::new(protocol::UUID::from_str(&uuid), resources, Some(write), Some(rx))) } fn spawn_reader(mut read: protocol::Conn) -> mpsc::Receiver> { @@ -209,7 +206,7 @@ impl Server { } pub fn dummy_server(resources: Arc>) -> Server { - let mut server = Server::new("dummy".to_owned(), protocol::UUID::default(), resources, None, None); + let mut server = Server::new(protocol::UUID::default(), resources, None, None); let mut rng = rand::thread_rng(); for x in -7*16 .. 7*16 { for z in -7*16 .. 7*16 { @@ -245,7 +242,7 @@ impl Server { } fn new( - username: String, uuid: protocol::UUID, + uuid: protocol::UUID, resources: Arc>, conn: Option, read_queue: Option>> ) -> Server { @@ -258,7 +255,6 @@ impl Server { let version = resources.read().unwrap().version(); Server { - username: username, uuid: uuid, conn: conn, read_queue: read_queue,