clippy
This commit is contained in:
parent
278e28ad18
commit
12677b2068
3 changed files with 12 additions and 16 deletions
|
@ -168,7 +168,7 @@ impl <'lua> NetworkServer<'lua> {
|
||||||
self.plugins.chat_message(client.player.as_ref().unwrap(), &msg.message);
|
self.plugins.chat_message(client.player.as_ref().unwrap(), &msg.message);
|
||||||
}
|
}
|
||||||
ServerBoundPacket::ChatCommand(msg) => {
|
ServerBoundPacket::ChatCommand(msg) => {
|
||||||
let mut parts = msg.message.splitn(1, " ");
|
let mut parts = msg.message.splitn(2, ' ');
|
||||||
if let Some(cmd) = parts.next() {
|
if let Some(cmd) = parts.next() {
|
||||||
if cmd == "qc" {
|
if cmd == "qc" {
|
||||||
client.send_packet(SystemChatMessage { message: json!({
|
client.send_packet(SystemChatMessage { message: json!({
|
||||||
|
@ -229,7 +229,7 @@ impl <'lua> NetworkServer<'lua> {
|
||||||
let (sig, data) = data.split_at(32);
|
let (sig, data) = data.split_at(32);
|
||||||
let mut mac = Hmac::<Sha256>::new_from_slice(self.config.velocity_secret.clone().unwrap().as_bytes())?;
|
let mut mac = Hmac::<Sha256>::new_from_slice(self.config.velocity_secret.clone().unwrap().as_bytes())?;
|
||||||
mac.update(data);
|
mac.update(data);
|
||||||
if let Err(_) = mac.verify_slice(sig) {
|
if mac.verify_slice(sig).is_err() {
|
||||||
client.send_packet(Disconnect { reason: json!({
|
client.send_packet(Disconnect { reason: json!({
|
||||||
"text": "Could not verify secret. Ensure that the secrets configured for Velocity and Quectocraft match."
|
"text": "Could not verify secret. Ensure that the secrets configured for Velocity and Quectocraft match."
|
||||||
})})?;
|
})})?;
|
||||||
|
|
|
@ -127,7 +127,7 @@ impl ClientBoundPacket for LoginPlay {
|
||||||
encoder.write_ubyte(self.prev_gamemode);
|
encoder.write_ubyte(self.prev_gamemode);
|
||||||
encoder.write_varint(self.dimensions.len() as i32);
|
encoder.write_varint(self.dimensions.len() as i32);
|
||||||
for dim in &self.dimensions {
|
for dim in &self.dimensions {
|
||||||
encoder.write_string(32767, &dim);
|
encoder.write_string(32767, dim);
|
||||||
}
|
}
|
||||||
encoder.write_bytes(&self.registry_codec);
|
encoder.write_bytes(&self.registry_codec);
|
||||||
encoder.write_string(32767, &self.dimension_type);
|
encoder.write_string(32767, &self.dimension_type);
|
||||||
|
|
|
@ -82,12 +82,6 @@ impl Commands {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum NodeError {
|
|
||||||
InvalidParent(i32),
|
|
||||||
InvalidRedirect(i32),
|
|
||||||
BadTypeData,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct CommandNode {
|
pub struct CommandNode {
|
||||||
executable: bool,
|
executable: bool,
|
||||||
|
@ -125,19 +119,20 @@ impl CommandNode {
|
||||||
match &self.type_data {
|
match &self.type_data {
|
||||||
CommandNodeType::Root => (),
|
CommandNodeType::Root => (),
|
||||||
CommandNodeType::Literal { name } => {
|
CommandNodeType::Literal { name } => {
|
||||||
encoder.write_string(32767, &name);
|
encoder.write_string(32767, name);
|
||||||
}
|
}
|
||||||
CommandNodeType::Argument { name, parser } => {
|
CommandNodeType::Argument { name, parser } => {
|
||||||
encoder.write_string(32767, &name);
|
encoder.write_string(32767, name);
|
||||||
parser.encode(encoder);
|
parser.encode(encoder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(suggestion) = &self.suggestion {
|
if let Some(suggestion) = &self.suggestion {
|
||||||
encoder.write_string(32767, &suggestion);
|
encoder.write_string(32767, suggestion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub enum Parser {
|
pub enum Parser {
|
||||||
Bool,
|
Bool,
|
||||||
|
@ -154,25 +149,25 @@ impl Parser {
|
||||||
Self::Bool => encoder.write_varint(0),
|
Self::Bool => encoder.write_varint(0),
|
||||||
Self::Float{ min, max } => {
|
Self::Float{ min, max } => {
|
||||||
encoder.write_varint(1);
|
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(min) = min { encoder.write_float(*min) };
|
||||||
if let Some(max) = max { encoder.write_float(*max) };
|
if let Some(max) = max { encoder.write_float(*max) };
|
||||||
},
|
},
|
||||||
Self::Double{ min, max } => {
|
Self::Double{ min, max } => {
|
||||||
encoder.write_varint(2);
|
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(min) = min { encoder.write_double(*min) };
|
||||||
if let Some(max) = max { encoder.write_double(*max) };
|
if let Some(max) = max { encoder.write_double(*max) };
|
||||||
},
|
},
|
||||||
Self::Int{ min, max } => {
|
Self::Int{ min, max } => {
|
||||||
encoder.write_varint(3);
|
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(min) = min { encoder.write_int(*min) };
|
||||||
if let Some(max) = max { encoder.write_int(*max) };
|
if let Some(max) = max { encoder.write_int(*max) };
|
||||||
},
|
},
|
||||||
Self::Long{ min, max } => {
|
Self::Long{ min, max } => {
|
||||||
encoder.write_varint(4);
|
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(min) = min { encoder.write_long(*min) };
|
||||||
if let Some(max) = max { encoder.write_long(*max) };
|
if let Some(max) = max { encoder.write_long(*max) };
|
||||||
},
|
},
|
||||||
|
@ -188,6 +183,7 @@ impl Parser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub enum StringKind {
|
pub enum StringKind {
|
||||||
Single,
|
Single,
|
||||||
|
|
Loading…
Reference in a new issue