aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets/login
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-05-01 23:06:56 -0500
committermat <github@matdoes.dev>2022-05-01 23:06:56 -0500
commitbec2da64d81883e3ea909452e71e17b9d22b2adc (patch)
treed4f94abc09534768f2531a4c23f54dcc2dab2814 /azalea-protocol/src/packets/login
parent4d75415130a008f83c3bd594ca4cefd01f3d53dd (diff)
parentdb2fcecdc38ea7a43b098c6282dd906b73981f97 (diff)
downloadazalea-drasl-bec2da64d81883e3ea909452e71e17b9d22b2adc.tar.xz
Merge branch 'main' into chunk-decoding
Diffstat (limited to 'azalea-protocol/src/packets/login')
-rwxr-xr-xazalea-protocol/src/packets/login/clientbound_game_profile_packet.rs16
-rwxr-xr-xazalea-protocol/src/packets/login/clientbound_hello_packet.rs12
-rwxr-xr-xazalea-protocol/src/packets/login/clientbound_login_compression_packet.rs8
3 files changed, 16 insertions, 20 deletions
diff --git a/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs b/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs
index ccf0f482..bcdcd105 100755
--- a/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs
+++ b/azalea-protocol/src/packets/login/clientbound_game_profile_packet.rs
@@ -1,3 +1,5 @@
+use std::io::Read;
+
use super::LoginPacket;
use crate::mc_buf::{Readable, Writable};
use azalea_auth::game_profile::GameProfile;
@@ -23,17 +25,15 @@ impl ClientboundGameProfilePacket {
Ok(())
}
- pub async fn read<T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send>(
- buf: &mut T,
- ) -> Result<LoginPacket, String> {
+ pub fn read(buf: &mut impl Read) -> Result<LoginPacket, String> {
// TODO: we have a thing to read from the uuid now
let uuid = Uuid::from_int_array([
- buf.read_int().await? as u32,
- buf.read_int().await? as u32,
- buf.read_int().await? as u32,
- buf.read_int().await? as u32,
+ buf.read_int()? as u32,
+ buf.read_int()? as u32,
+ buf.read_int()? as u32,
+ buf.read_int()? as u32,
]);
- let name = buf.read_utf_with_len(16).await?;
+ let name = buf.read_utf_with_len(16)?;
Ok(ClientboundGameProfilePacket {
game_profile: GameProfile::new(uuid, name),
}
diff --git a/azalea-protocol/src/packets/login/clientbound_hello_packet.rs b/azalea-protocol/src/packets/login/clientbound_hello_packet.rs
index 20af1bec..06f346c2 100755
--- a/azalea-protocol/src/packets/login/clientbound_hello_packet.rs
+++ b/azalea-protocol/src/packets/login/clientbound_hello_packet.rs
@@ -1,4 +1,4 @@
-use std::hash::Hash;
+use std::{hash::Hash, io::Read};
use super::LoginPacket;
use crate::mc_buf::Readable;
@@ -19,12 +19,10 @@ impl ClientboundHelloPacket {
panic!("ClientboundHelloPacket::write not implemented")
}
- pub async fn read<T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send>(
- buf: &mut T,
- ) -> Result<LoginPacket, String> {
- let server_id = buf.read_utf_with_len(20).await?;
- let public_key = buf.read_byte_array().await?;
- let nonce = buf.read_byte_array().await?;
+ pub fn read(buf: &mut impl Read) -> Result<LoginPacket, String> {
+ let server_id = buf.read_utf_with_len(20)?;
+ let public_key = buf.read_byte_array()?;
+ let nonce = buf.read_byte_array()?;
Ok(ClientboundHelloPacket {
server_id,
diff --git a/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs b/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs
index a88c6cbf..a5ab78bb 100755
--- a/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs
+++ b/azalea-protocol/src/packets/login/clientbound_login_compression_packet.rs
@@ -1,4 +1,4 @@
-use std::hash::Hash;
+use std::{hash::Hash, io::Read};
use crate::mc_buf::{Readable, Writable};
@@ -19,10 +19,8 @@ impl ClientboundLoginCompressionPacket {
Ok(())
}
- pub async fn read<T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send>(
- buf: &mut T,
- ) -> Result<LoginPacket, String> {
- let compression_threshold = buf.read_varint().await?;
+ pub fn read(buf: &mut impl Read) -> Result<LoginPacket, String> {
+ let compression_threshold = buf.read_varint()?;
Ok(ClientboundLoginCompressionPacket {
compression_threshold,