aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xazalea-client/src/connect.rs15
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs2
-rwxr-xr-xazalea-protocol/src/read.rs24
3 files changed, 18 insertions, 23 deletions
diff --git a/azalea-client/src/connect.rs b/azalea-client/src/connect.rs
index 2aa25f2d..b0d7dffc 100755
--- a/azalea-client/src/connect.rs
+++ b/azalea-client/src/connect.rs
@@ -11,14 +11,7 @@ use azalea_protocol::{
},
resolver, ServerAddress,
};
-use std::{
- borrow::BorrowMut,
- cell::RefCell,
- future::Future,
- pin::Pin,
- rc::Rc,
- sync::{Arc, Weak},
-};
+use std::sync::Arc;
use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender};
use tokio::sync::Mutex;
@@ -88,8 +81,8 @@ impl Client {
conn.write(
ServerboundKeyPacket {
- nonce: e.encrypted_nonce.into(),
- shared_secret: e.encrypted_public_key.into(),
+ nonce: e.encrypted_nonce,
+ shared_secret: e.encrypted_public_key,
}
.get(),
)
@@ -237,6 +230,6 @@ impl Account {
}
pub async fn join(&self, address: &ServerAddress) -> Result<Client, String> {
- Client::join(&self, address).await
+ Client::join(self, address).await
}
}
diff --git a/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs b/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs
index 33b710d5..afaa7fdd 100755
--- a/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs
@@ -76,7 +76,7 @@ impl<T: McBufWritable> McBufWritable for BrigadierNumber<T> {
if self.max.is_some() {
flags |= 0x02;
}
- buf.write_i8(flags);
+ buf.write_byte(flags)?;
if let Some(min) = &self.min {
min.write_into(buf)?;
}
diff --git a/azalea-protocol/src/read.rs b/azalea-protocol/src/read.rs
index b249e3d7..51224499 100755
--- a/azalea-protocol/src/read.rs
+++ b/azalea-protocol/src/read.rs
@@ -1,4 +1,8 @@
-use std::{cell::Cell, pin::Pin};
+use std::{
+ cell::Cell,
+ pin::Pin,
+ task::{Context, Poll},
+};
use crate::{connect::PacketFlow, mc_buf::Readable, packets::ProtocolPacket};
use async_compression::tokio::bufread::ZlibDecoder;
@@ -35,13 +39,13 @@ where
{
// Packet ID
let packet_id = stream.read_varint().await?;
- Ok(P::read(packet_id.try_into().unwrap(), flow, stream).await?)
+ P::read(packet_id.try_into().unwrap(), flow, stream).await
}
// this is always true in multiplayer, false in singleplayer
static VALIDATE_DECOMPRESSED: bool = true;
-pub static MAXIMUM_UNCOMPRESSED_LENGTH: u32 = 8388608;
+pub static MAXIMUM_UNCOMPRESSED_LENGTH: u32 = 2097152;
async fn compression_decoder<R>(
stream: &mut R,
@@ -103,28 +107,26 @@ where
impl<R> AsyncRead for EncryptedStream<'_, R>
where
- R: AsyncRead + std::marker::Unpin + std::marker::Send,
+ R: AsyncRead + Unpin + Send,
{
fn poll_read(
mut self: Pin<&mut Self>,
- cx: &mut std::task::Context<'_>,
+ cx: &mut Context<'_>,
buf: &mut tokio::io::ReadBuf<'_>,
- ) -> std::task::Poll<std::io::Result<()>> {
+ ) -> Poll<std::io::Result<()>> {
// i hate this
let polled = self.as_mut().stream.as_mut().poll_read(cx, buf);
match polled {
- std::task::Poll::Ready(r) => {
+ Poll::Ready(r) => {
if let Some(cipher) = self.as_mut().cipher.get_mut() {
azalea_auth::encryption::decrypt_packet(cipher, buf.initialized_mut());
}
match r {
- Ok(()) => std::task::Poll::Ready(Ok(())),
+ Ok(()) => Poll::Ready(Ok(())),
Err(e) => panic!("{:?}", e),
}
}
- std::task::Poll::Pending => {
- return std::task::Poll::Pending;
- }
+ Poll::Pending => Poll::Pending,
}
}
}