This commit is contained in:
TriMill 2022-12-18 00:50:37 -05:00
parent 278e28ad18
commit 12677b2068
3 changed files with 12 additions and 16 deletions

View file

@ -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::<Sha256>::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."
})})?;

View file

@ -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);

View file

@ -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,