diff --git a/src/network/server.rs b/src/network/server.rs index 7947241..7786e83 100644 --- a/src/network/server.rs +++ b/src/network/server.rs @@ -168,7 +168,7 @@ impl <'lua> NetworkServer<'lua> { self.plugins.chat_message(client.player.as_ref().unwrap(), &msg.message); } ServerBoundPacket::ChatCommand(msg) => { - let mut parts = msg.message.splitn(1, " "); + let mut parts = msg.message.splitn(2, ' '); if let Some(cmd) = parts.next() { if cmd == "qc" { client.send_packet(SystemChatMessage { message: json!({ @@ -229,7 +229,7 @@ impl <'lua> NetworkServer<'lua> { let (sig, data) = data.split_at(32); let mut mac = Hmac::::new_from_slice(self.config.velocity_secret.clone().unwrap().as_bytes())?; mac.update(data); - if let Err(_) = mac.verify_slice(sig) { + if mac.verify_slice(sig).is_err() { client.send_packet(Disconnect { reason: json!({ "text": "Could not verify secret. Ensure that the secrets configured for Velocity and Quectocraft match." })})?; diff --git a/src/protocol/clientbound.rs b/src/protocol/clientbound.rs index 60db1b2..1e50533 100644 --- a/src/protocol/clientbound.rs +++ b/src/protocol/clientbound.rs @@ -127,7 +127,7 @@ impl ClientBoundPacket for LoginPlay { encoder.write_ubyte(self.prev_gamemode); encoder.write_varint(self.dimensions.len() as i32); for dim in &self.dimensions { - encoder.write_string(32767, &dim); + encoder.write_string(32767, dim); } encoder.write_bytes(&self.registry_codec); encoder.write_string(32767, &self.dimension_type); diff --git a/src/protocol/command.rs b/src/protocol/command.rs index 7cbb38a..c35bcd6 100644 --- a/src/protocol/command.rs +++ b/src/protocol/command.rs @@ -82,12 +82,6 @@ impl Commands { } -pub enum NodeError { - InvalidParent(i32), - InvalidRedirect(i32), - BadTypeData, -} - #[derive(Debug, Clone)] pub struct CommandNode { executable: bool, @@ -125,19 +119,20 @@ impl CommandNode { match &self.type_data { CommandNodeType::Root => (), CommandNodeType::Literal { name } => { - encoder.write_string(32767, &name); + encoder.write_string(32767, name); } CommandNodeType::Argument { name, parser } => { - encoder.write_string(32767, &name); + encoder.write_string(32767, name); parser.encode(encoder); } } if let Some(suggestion) = &self.suggestion { - encoder.write_string(32767, &suggestion); + encoder.write_string(32767, suggestion); } } } +#[allow(unused)] #[derive(Debug, Clone, Copy)] pub enum Parser { Bool, @@ -154,25 +149,25 @@ impl Parser { Self::Bool => encoder.write_varint(0), Self::Float{ min, max } => { encoder.write_varint(1); - encoder.write_byte( if min.is_some() { 1 } else { 0 } + if max.is_some() { 2 } else { 0 } ); + encoder.write_byte( i8::from(min.is_some()) + 2 * i8::from(max.is_some()) ); if let Some(min) = min { encoder.write_float(*min) }; if let Some(max) = max { encoder.write_float(*max) }; }, Self::Double{ min, max } => { encoder.write_varint(2); - encoder.write_byte( if min.is_some() { 1 } else { 0 } + if max.is_some() { 2 } else { 0 } ); + encoder.write_byte( i8::from(min.is_some()) + 2 * i8::from(max.is_some()) ); if let Some(min) = min { encoder.write_double(*min) }; if let Some(max) = max { encoder.write_double(*max) }; }, Self::Int{ min, max } => { encoder.write_varint(3); - encoder.write_byte( if min.is_some() { 1 } else { 0 } + if max.is_some() { 2 } else { 0 } ); + encoder.write_byte( i8::from(min.is_some()) + 2 * i8::from(max.is_some()) ); if let Some(min) = min { encoder.write_int(*min) }; if let Some(max) = max { encoder.write_int(*max) }; }, Self::Long{ min, max } => { encoder.write_varint(4); - encoder.write_byte( if min.is_some() { 1 } else { 0 } + if max.is_some() { 2 } else { 0 } ); + encoder.write_byte( i8::from(min.is_some()) + 2 * i8::from(max.is_some()) ); if let Some(min) = min { encoder.write_long(*min) }; if let Some(max) = max { encoder.write_long(*max) }; }, @@ -188,6 +183,7 @@ impl Parser { } } +#[allow(unused)] #[derive(Debug, Clone, Copy)] pub enum StringKind { Single,