aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-12-08 18:39:35 -0600
committermat <github@matdoes.dev>2022-12-08 18:39:35 -0600
commit70e2dfed16da8d5130460ea15b47701e622f4a9f (patch)
tree41f670baf3a05ed180880ec2a11d8e5f6a1a1599 /azalea-protocol/src
parentf2076daba5cfcce81399b075ba9258fbdc2012fa (diff)
downloadazalea-drasl-70e2dfed16da8d5130460ea15b47701e622f4a9f.tar.xz
wrap_comments = true
Diffstat (limited to 'azalea-protocol/src')
-rwxr-xr-xazalea-protocol/src/connect.rs15
-rw-r--r--azalea-protocol/src/lib.rs3
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_add_player_packet.rs3
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_commands_packet.rs3
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_map_item_data_packet.rs3
-rw-r--r--azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs7
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs10
-rwxr-xr-xazalea-protocol/src/packets/game/serverbound_set_jigsaw_block_packet.rs3
-rwxr-xr-xazalea-protocol/src/packets/mod.rs3
-rwxr-xr-xazalea-protocol/src/read.rs37
-rwxr-xr-xazalea-protocol/src/resolver.rs7
11 files changed, 56 insertions, 38 deletions
diff --git a/azalea-protocol/src/connect.rs b/azalea-protocol/src/connect.rs
index b21572e3..48401d03 100755
--- a/azalea-protocol/src/connect.rs
+++ b/azalea-protocol/src/connect.rs
@@ -226,12 +226,14 @@ impl Connection<ClientboundHandshakePacket, ServerboundHandshakePacket> {
})
}
- /// Change our state from handshake to login. This is the state that is used for logging in.
+ /// Change our state from handshake to login. This is the state that is used
+ /// for logging in.
pub fn login(self) -> Connection<ClientboundLoginPacket, ServerboundLoginPacket> {
Connection::from(self)
}
- /// Change our state from handshake to status. This is the state that is used for pinging the server.
+ /// Change our state from handshake to status. This is the state that is
+ /// used for pinging the server.
pub fn status(self) -> Connection<ClientboundStatusPacket, ServerboundStatusPacket> {
Connection::from(self)
}
@@ -252,14 +254,16 @@ impl Connection<ClientboundLoginPacket, ServerboundLoginPacket> {
}
}
- /// Set the encryption key that is used to encrypt and decrypt packets. It's the same for both reading and writing.
+ /// Set the encryption key that is used to encrypt and decrypt packets. It's
+ /// the same for both reading and writing.
pub fn set_encryption_key(&mut self, key: [u8; 16]) {
let (enc_cipher, dec_cipher) = azalea_crypto::create_cipher(&key);
self.reader.dec_cipher = Some(dec_cipher);
self.writer.enc_cipher = Some(enc_cipher);
}
- /// Change our state from login to game. This is the state that's used when you're actually in the game.
+ /// Change our state from login to game. This is the state that's used when
+ /// you're actually in the game.
pub fn game(self) -> Connection<ClientboundGamePacket, ServerboundGamePacket> {
Connection::from(self)
}
@@ -342,7 +346,8 @@ where
R1: ProtocolPacket + Debug,
W1: ProtocolPacket + Debug,
{
- /// Creates a `Connection` of a type from a `Connection` of another type. Useful for servers or custom packets.
+ /// Creates a `Connection` of a type from a `Connection` of another type.
+ /// Useful for servers or custom packets.
pub fn from<R2, W2>(connection: Connection<R1, W1>) -> Connection<R2, W2>
where
R2: ProtocolPacket + Debug,
diff --git a/azalea-protocol/src/lib.rs b/azalea-protocol/src/lib.rs
index 84aa35cc..3f838d2a 100644
--- a/azalea-protocol/src/lib.rs
+++ b/azalea-protocol/src/lib.rs
@@ -44,7 +44,8 @@ pub struct ServerAddress {
impl<'a> TryFrom<&'a str> for ServerAddress {
type Error = String;
- /// Convert a Minecraft server address (host:port, the port is optional) to a ServerAddress
+ /// Convert a Minecraft server address (host:port, the port is optional) to
+ /// a ServerAddress
fn try_from(string: &str) -> Result<Self, Self::Error> {
if string.is_empty() {
return Err("Empty string".to_string());
diff --git a/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs b/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs
index 03585f06..58c7b0a3 100755
--- a/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_add_player_packet.rs
@@ -4,7 +4,8 @@ use azalea_protocol_macros::ClientboundGamePacket;
use azalea_world::entity::{metadata, EntityData, EntityMetadata};
use uuid::Uuid;
-/// This packet is sent by the server when a player comes into visible range, not when a player joins.
+/// This packet is sent by the server when a player comes into visible range,
+/// not when a player joins.
#[derive(Clone, Debug, McBuf, ClientboundGamePacket)]
pub struct ClientboundAddPlayerPacket {
#[var]
diff --git a/azalea-protocol/src/packets/game/clientbound_commands_packet.rs b/azalea-protocol/src/packets/game/clientbound_commands_packet.rs
index ce578176..39e807cf 100755
--- a/azalea-protocol/src/packets/game/clientbound_commands_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_commands_packet.rs
@@ -73,7 +73,8 @@ impl<T: McBufWritable> McBufWritable for BrigadierNumber<T> {
pub enum BrigadierString {
/// Reads a single word
SingleWord = 0,
- // If it starts with a ", keeps reading until another " (allowing escaping with \). Otherwise behaves the same as SINGLE_WORD
+ // If it starts with a ", keeps reading until another " (allowing escaping with \). Otherwise
+ // behaves the same as SINGLE_WORD
QuotablePhrase = 1,
// Reads the rest of the content after the cursor. Quotes will not be removed.
GreedyPhrase = 2,
diff --git a/azalea-protocol/src/packets/game/clientbound_map_item_data_packet.rs b/azalea-protocol/src/packets/game/clientbound_map_item_data_packet.rs
index 07e49687..94593e3e 100755
--- a/azalea-protocol/src/packets/game/clientbound_map_item_data_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_map_item_data_packet.rs
@@ -73,7 +73,8 @@ pub struct MapDecoration {
pub decoration_type: DecorationType,
pub x: i8,
pub y: i8,
- /// Minecraft does & 15 on this value, azalea-protocol doesn't. I don't think it matters.
+ /// Minecraft does & 15 on this value, azalea-protocol doesn't. I don't
+ /// think it matters.
pub rot: i8,
pub name: Option<Component>,
}
diff --git a/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs
index f22fb608..a735c907 100644
--- a/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_player_chat_packet.rs
@@ -83,8 +83,8 @@ pub struct MessageSignatureCache {
// }
// impl PackedSignedMessageBody {
-// pub fn unpack(&self, unpacker: impl Fn(u32) -> Option<SignedMessageBody>) {}
-// }
+// pub fn unpack(&self, unpacker: impl Fn(u32) -> Option<SignedMessageBody>)
+// {} }
impl ClientboundPlayerChatPacket {
/// Returns the content of the message. If you want to get the Component
@@ -176,7 +176,8 @@ mod tests {
use super::*;
use std::backtrace::Backtrace;
- // you can remove or update this test if it breaks because mojang changed the structure of the packet again
+ // you can remove or update this test if it breaks because mojang changed the
+ // structure of the packet again
#[test]
fn test_player_chat_packet() {
let data: [u8; 295] = [
diff --git a/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs
index 5f63dd1a..b18193d0 100755
--- a/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_update_advancements_packet.rs
@@ -133,9 +133,9 @@ pub struct CriterionProgress {
// parent_id: None,
// display: Some(DisplayInfo {
// title: Component::from("title".to_string()),
-// description: Component::from("description".to_string()),
-// icon: Slot::Empty,
-// frame: FrameType::Task,
+// description:
+// Component::from("description".to_string()), icon:
+// Slot::Empty, frame: FrameType::Task,
// show_toast: true,
// hidden: false,
// background: None,
@@ -164,7 +164,7 @@ pub struct CriterionProgress {
// .collect(),
// };
// packet.write_into(&mut buf).unwrap();
-// let packet = ClientboundUpdateAdvancementsPacket::read_from(&mut buf).unwrap();
-// assert_eq!(packet.reset, true);
+// let packet = ClientboundUpdateAdvancementsPacket::read_from(&mut
+// buf).unwrap(); assert_eq!(packet.reset, true);
// }
// }
diff --git a/azalea-protocol/src/packets/game/serverbound_set_jigsaw_block_packet.rs b/azalea-protocol/src/packets/game/serverbound_set_jigsaw_block_packet.rs
index 78f77754..989009f4 100755
--- a/azalea-protocol/src/packets/game/serverbound_set_jigsaw_block_packet.rs
+++ b/azalea-protocol/src/packets/game/serverbound_set_jigsaw_block_packet.rs
@@ -15,7 +15,8 @@ pub struct ServerboundSetJigsawBlockPacket {
pub target: ResourceLocation,
pub pool: ResourceLocation,
pub final_state: String,
- pub joint: String, // TODO: Does JigsawBlockEntity$JointType::getSerializedName, may not be implemented
+ pub joint: String, /* TODO: Does JigsawBlockEntity$JointType::getSerializedName, may not be
+ * implemented */
}
pub enum JointType {
diff --git a/azalea-protocol/src/packets/mod.rs b/azalea-protocol/src/packets/mod.rs
index 76ddd05d..508d06a6 100755
--- a/azalea-protocol/src/packets/mod.rs
+++ b/azalea-protocol/src/packets/mod.rs
@@ -7,7 +7,8 @@ use crate::read::ReadPacketError;
use azalea_buf::{BufReadError, McBufVarReadable, McBufVarWritable, McBufWritable};
use std::io::{Cursor, Write};
-// TODO: rename the packet files to just like clientbound_add_entity instead of clientbound_add_entity_packet
+// TODO: rename the packet files to just like clientbound_add_entity instead of
+// clientbound_add_entity_packet
pub const PROTOCOL_VERSION: u32 = 761;
diff --git a/azalea-protocol/src/read.rs b/azalea-protocol/src/read.rs
index 24a434f3..7f81cfef 100755
--- a/azalea-protocol/src/read.rs
+++ b/azalea-protocol/src/read.rs
@@ -261,27 +261,30 @@ where
// #[cfg(test)]
// mod tests {
// use super::*;
-// use crate::packets::game::{clientbound_player_chat_packet::ChatType, ClientboundGamePacket};
-// use std::io::Cursor;
+// use crate::packets::game::{clientbound_player_chat_packet::ChatType,
+// ClientboundGamePacket}; use std::io::Cursor;
// #[tokio::test]
// async fn test_read_packet() {
// let mut buf: Cursor<&[u8]> = Cursor::new(&[
-// 51, 0, 12, 177, 250, 155, 132, 106, 60, 218, 161, 217, 90, 157, 105, 57, 206, 20, 0, 5,
-// 104, 101, 108, 108, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 116,
-// 123, 34, 101, 120, 116, 114, 97, 34, 58, 91, 123, 34, 99, 111, 108, 111, 114, 34, 58,
-// 34, 103, 114, 97, 121, 34, 44, 34, 116, 101, 120, 116, 34, 58, 34, 91, 77, 69, 77, 66,
-// 69, 82, 93, 32, 112, 108, 97, 121, 101, 114, 49, 34, 125, 44, 123, 34, 116, 101, 120,
-// 116, 34, 58, 34, 32, 34, 125, 44, 123, 34, 99, 111, 108, 111, 114, 34, 58, 34, 103,
-// 114, 97, 121, 34, 44, 34, 116, 101, 120, 116, 34, 58, 34, 92, 117, 48, 48, 51, 101, 32,
-// 104, 101, 108, 108, 111, 34, 125, 93, 44, 34, 116, 101, 120, 116, 34, 58, 34, 34, 125,
-// 0, 7, 64, 123, 34, 101, 120, 116, 114, 97, 34, 58, 91, 123, 34, 99, 111, 108, 111, 114,
-// 34, 58, 34, 103, 114, 97, 121, 34, 44, 34, 116, 101, 120, 116, 34, 58, 34, 91, 77, 69,
-// 77, 66, 69, 82, 93, 32, 112, 108, 97, 121, 101, 114, 49, 34, 125, 93, 44, 34, 116, 101,
-// 120, 116, 34, 58, 34, 34, 125, 0,
-// ]);
-// let packet = packet_decoder::<ClientboundGamePacket>(&mut buf).unwrap();
-// match &packet {
+// 51, 0, 12, 177, 250, 155, 132, 106, 60, 218, 161, 217, 90, 157,
+// 105, 57, 206, 20, 0, 5, 104, 101, 108, 108, 111, 0, 0, 0, 0, 0,
+// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 116, 123, 34, 101, 120,
+// 116, 114, 97, 34, 58, 91, 123, 34, 99, 111, 108, 111, 114, 34, 58,
+// 34, 103, 114, 97, 121, 34, 44, 34, 116, 101, 120, 116, 34, 58,
+// 34, 91, 77, 69, 77, 66, 69, 82, 93, 32, 112, 108, 97, 121, 101,
+// 114, 49, 34, 125, 44, 123, 34, 116, 101, 120, 116, 34, 58, 34,
+// 32, 34, 125, 44, 123, 34, 99, 111, 108, 111, 114, 34, 58, 34, 103,
+// 114, 97, 121, 34, 44, 34, 116, 101, 120, 116, 34, 58, 34, 92,
+// 117, 48, 48, 51, 101, 32, 104, 101, 108, 108, 111, 34, 125, 93,
+// 44, 34, 116, 101, 120, 116, 34, 58, 34, 34, 125, 0, 7, 64, 123,
+// 34, 101, 120, 116, 114, 97, 34, 58, 91, 123, 34, 99, 111, 108, 111, 114,
+// 34, 58, 34, 103, 114, 97, 121, 34, 44, 34, 116, 101, 120, 116,
+// 34, 58, 34, 91, 77, 69, 77, 66, 69, 82, 93, 32, 112, 108, 97,
+// 121, 101, 114, 49, 34, 125, 93, 44, 34, 116, 101, 120, 116, 34,
+// 58, 34, 34, 125, 0, ]);
+// let packet = packet_decoder::<ClientboundGamePacket>(&mut
+// buf).unwrap(); match &packet {
// ClientboundGamePacket::PlayerChat(m) => {
// assert_eq!(
// m.chat_type.chat_type,
diff --git a/azalea-protocol/src/resolver.rs b/azalea-protocol/src/resolver.rs
index 26baf2f9..dde5af3a 100755
--- a/azalea-protocol/src/resolver.rs
+++ b/azalea-protocol/src/resolver.rs
@@ -26,7 +26,9 @@ pub async fn resolve_address(address: &ServerAddress) -> Result<SocketAddr, Reso
return Ok(SocketAddr::new(ip, address.port));
}
- // we specify Cloudflare instead of the default resolver because trust_dns_resolver has an issue on Windows where it's really slow using the default resolver
+ // we specify Cloudflare instead of the default resolver because
+ // trust_dns_resolver has an issue on Windows where it's really slow using the
+ // default resolver
let resolver =
TokioAsyncResolver::tokio(ResolverConfig::cloudflare(), ResolverOpts::default()).unwrap();
@@ -35,7 +37,8 @@ pub async fn resolve_address(address: &ServerAddress) -> Result<SocketAddr, Reso
.srv_lookup(format!("_minecraft._tcp.{}", address.host).as_str())
.await;
- // if it resolves that means it's a redirect so we call resolve_address again with the new host
+ // if it resolves that means it's a redirect so we call resolve_address again
+ // with the new host
if let Ok(redirect_result) = srv_redirect_result {
let redirect_srv = redirect_result
.iter()