aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-05-03 18:20:24 +0000
committermat <github@matdoes.dev>2022-05-03 18:20:24 +0000
commitc9878129274258a30dc3ee0ecbd064b4fcf9bc6e (patch)
tree07e03b13eb71b4231159d42b5773e31371e83858 /azalea-protocol
parent477c367fc44a2b5c139845f7e8307c6c276d95ee (diff)
downloadazalea-drasl-c9878129274258a30dc3ee0ecbd064b4fcf9bc6e.tar.xz
clippy
Diffstat (limited to 'azalea-protocol')
-rwxr-xr-xazalea-protocol/packet-macros/src/lib.rs13
-rwxr-xr-xazalea-protocol/src/mc_buf/read.rs6
-rwxr-xr-xazalea-protocol/src/mc_buf/write.rs8
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs18
-rw-r--r--azalea-protocol/src/packets/game/clientbound_light_update_packet.rs1
-rwxr-xr-xazalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs8
-rw-r--r--azalea-protocol/src/packets/game/clientbound_player_position_packet.rs10
-rw-r--r--azalea-protocol/src/packets/game/clientbound_recipe_packet.rs4
-rw-r--r--azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs4
-rw-r--r--azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs2
-rw-r--r--azalea-protocol/src/packets/login/serverbound_key_packet.rs2
-rwxr-xr-xazalea-protocol/src/write.rs5
12 files changed, 36 insertions, 45 deletions
diff --git a/azalea-protocol/packet-macros/src/lib.rs b/azalea-protocol/packet-macros/src/lib.rs
index 35abf642..dec153ec 100755
--- a/azalea-protocol/packet-macros/src/lib.rs
+++ b/azalea-protocol/packet-macros/src/lib.rs
@@ -232,13 +232,12 @@ struct PacketIdMap {
impl Parse for PacketIdMap {
fn parse(input: ParseStream) -> Result<Self> {
let mut packets = vec![];
- loop {
- // 0x0e: clientbound_change_difficulty_packet::ClientboundChangeDifficultyPacket,
- // 0x0e
- let packet_id: LitInt = match input.parse() {
- Ok(i) => i,
- Err(_) => break,
- };
+
+ // example:
+ // 0x0e: clientbound_change_difficulty_packet::ClientboundChangeDifficultyPacket,
+
+ // 0x0e
+ while let Ok(packet_id) = input.parse::<LitInt>() {
let packet_id = packet_id.base10_parse::<u32>()?;
// :
input.parse::<Token![:]>()?;
diff --git a/azalea-protocol/src/mc_buf/read.rs b/azalea-protocol/src/mc_buf/read.rs
index 68c9cb3f..e1ae321c 100755
--- a/azalea-protocol/src/mc_buf/read.rs
+++ b/azalea-protocol/src/mc_buf/read.rs
@@ -1,10 +1,10 @@
-use super::{BitSet, UnsizedByteArray, MAX_STRING_LENGTH};
+use super::{UnsizedByteArray, MAX_STRING_LENGTH};
use azalea_chat::component::Component;
use azalea_core::{
difficulty::Difficulty, game_type::GameType, resource_location::ResourceLocation,
serializable_uuid::SerializableUuid, BlockPos, Direction, Slot, SlotData,
};
-use byteorder::{ReadBytesExt, WriteBytesExt, BE};
+use byteorder::{ReadBytesExt, BE};
use serde::Deserialize;
use std::io::Read;
use tokio::io::{AsyncRead, AsyncReadExt};
@@ -421,7 +421,7 @@ impl McBufReadable for Component {
fn read_into(buf: &mut impl Read) -> Result<Self, String> {
let string = buf.read_utf()?;
let json: serde_json::Value = serde_json::from_str(string.as_str())
- .map_err(|e| "Component isn't valid JSON".to_string())?;
+ .map_err(|_| "Component isn't valid JSON".to_string())?;
let component = Component::deserialize(json).map_err(|e| e.to_string())?;
Ok(component)
}
diff --git a/azalea-protocol/src/mc_buf/write.rs b/azalea-protocol/src/mc_buf/write.rs
index 34bcafeb..3a4a02f8 100755
--- a/azalea-protocol/src/mc_buf/write.rs
+++ b/azalea-protocol/src/mc_buf/write.rs
@@ -20,8 +20,8 @@ pub trait Writable: Write {
Ok(())
}
- fn write_int_id_list(&mut self, list: &Vec<i32>) -> Result<(), std::io::Error> {
- self.write_list(&list, |buf, n| buf.write_varint(*n))
+ fn write_int_id_list(&mut self, list: &[i32]) -> Result<(), std::io::Error> {
+ self.write_list(list, |buf, n| buf.write_varint(*n))
}
fn write_map<KF, VF, KT, VT>(
@@ -47,7 +47,7 @@ pub trait Writable: Write {
}
fn write_bytes(&mut self, bytes: &[u8]) -> Result<(), std::io::Error> {
- self.write_all(bytes);
+ self.write_all(bytes)?;
Ok(())
}
@@ -333,7 +333,7 @@ impl McBufWritable for Component {
// let component = Component::deserialize(json).map_err(|e| e.to_string())?;
// Ok(component)
// }
- fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn write_into(&self, _buf: &mut impl Write) -> Result<(), std::io::Error> {
// component doesn't have serialize implemented yet
todo!()
}
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 27f4fb16..6743c3af 100755
--- a/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_declare_commands_packet.rs
@@ -281,7 +281,7 @@ impl McBufReadable for BrigadierParser {
}
}
-// azalea_brigadier::tree::CommandNode
+// TODO: BrigadierNodeStub should have more stuff
impl McBufReadable for BrigadierNodeStub {
fn read_into(buf: &mut impl Read) -> Result<Self, String> {
let flags = u8::read_into(buf)?;
@@ -292,20 +292,18 @@ impl McBufReadable for BrigadierNodeStub {
}
let node_type = flags & 0x03;
- let is_executable = flags & 0x04 != 0;
+ let _is_executable = flags & 0x04 != 0;
let has_redirect = flags & 0x08 != 0;
let has_suggestions_type = flags & 0x10 != 0;
- let children = buf.read_int_id_list()?;
- let redirect_node = if has_redirect { buf.read_varint()? } else { 0 };
+ let _children = buf.read_int_id_list()?;
+ let _redirect_node = if has_redirect { buf.read_varint()? } else { 0 };
// argument node
if node_type == 2 {
- let name = buf.read_utf()?;
-
- let parser = BrigadierParser::read_into(buf)?;
-
- let suggestions_type = if has_suggestions_type {
+ let _name = buf.read_utf()?;
+ let _parser = BrigadierParser::read_into(buf)?;
+ let _suggestions_type = if has_suggestions_type {
Some(buf.read_resource_location()?)
} else {
None
@@ -314,7 +312,7 @@ impl McBufReadable for BrigadierNodeStub {
}
// literal node
if node_type == 1 {
- let name = buf.read_utf()?;
+ let _name = buf.read_utf()?;
return Ok(BrigadierNodeStub {});
}
Ok(BrigadierNodeStub {})
diff --git a/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs b/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs
index c97eacff..e83d1e87 100644
--- a/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_light_update_packet.rs
@@ -1,5 +1,4 @@
use crate::mc_buf::BitSet;
-use azalea_core::{game_type::GameType, resource_location::ResourceLocation};
use packet_macros::{GamePacket, McBufReadable, McBufWritable};
#[derive(Clone, Debug, GamePacket)]
diff --git a/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs
index cd645fe6..ed27ecf3 100755
--- a/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_player_abilities_packet.rs
@@ -34,16 +34,16 @@ impl McBufWritable for PlayerAbilitiesFlags {
fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
let mut byte = 0;
if self.invulnerable {
- byte = byte | 1;
+ byte |= 0b1;
}
if self.flying {
- byte = byte | 2;
+ byte |= 0b10;
}
if self.can_fly {
- byte = byte | 4;
+ byte |= 0b100;
}
if self.instant_break {
- byte = byte | 8;
+ byte |= 0b1000;
}
u8::write_into(&byte, buf)
}
diff --git a/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs b/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs
index cac4665d..c2bef8fa 100644
--- a/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_player_position_packet.rs
@@ -43,19 +43,19 @@ impl McBufWritable for RelativeArguments {
fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
let mut byte = 0;
if self.x {
- byte = byte | 0b1;
+ byte |= 0b1;
}
if self.y {
- byte = byte | 0b10;
+ byte |= 0b10;
}
if self.z {
- byte = byte | 0b100;
+ byte |= 0b100;
}
if self.y_rot {
- byte = byte | 0b1000;
+ byte |= 0b1000;
}
if self.x_rot {
- byte = byte | 0b10000;
+ byte |= 0b10000;
}
u8::write_into(&byte, buf)
}
diff --git a/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs b/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs
index 543fb64c..fa0d58f0 100644
--- a/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_recipe_packet.rs
@@ -1,5 +1,5 @@
use crate::mc_buf::{McBufReadable, McBufWritable, Readable, Writable};
-use azalea_core::{resource_location::ResourceLocation, Slot};
+use azalea_core::resource_location::ResourceLocation;
use packet_macros::{GamePacket, McBufReadable, McBufWritable};
use std::io::{Read, Write};
@@ -41,7 +41,7 @@ impl McBufWritable for State {
}
impl McBufReadable for State {
fn read_into(buf: &mut impl Read) -> Result<Self, String> {
- let state = buf.read_varint()?.try_into().unwrap();
+ let state = buf.read_varint()?;
Ok(match state {
0 => State::Init,
1 => State::Add,
diff --git a/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs b/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs
index 5d288518..ca726c39 100644
--- a/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_set_entity_data_packet.rs
@@ -123,7 +123,7 @@ impl McBufReadable for EntityDataValue {
}
impl McBufWritable for EntityDataValue {
- fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn write_into(&self, _buf: &mut impl Write) -> Result<(), std::io::Error> {
todo!();
}
}
@@ -398,7 +398,7 @@ impl McBufReadable for ParticleData {
}
impl McBufWritable for ParticleData {
- fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn write_into(&self, _buf: &mut impl Write) -> Result<(), std::io::Error> {
todo!()
}
}
diff --git a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs
index d15e10c3..9bdea26e 100644
--- a/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs
+++ b/azalea-protocol/src/packets/game/clientbound_update_recipes_packet.rs
@@ -122,7 +122,7 @@ pub struct Ingredient {
}
impl McBufWritable for Recipe {
- fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
+ fn write_into(&self, _buf: &mut impl Write) -> Result<(), std::io::Error> {
todo!()
}
}
diff --git a/azalea-protocol/src/packets/login/serverbound_key_packet.rs b/azalea-protocol/src/packets/login/serverbound_key_packet.rs
index f402d357..2ff8dda6 100644
--- a/azalea-protocol/src/packets/login/serverbound_key_packet.rs
+++ b/azalea-protocol/src/packets/login/serverbound_key_packet.rs
@@ -1,5 +1,3 @@
-use super::LoginPacket;
-use crate::mc_buf::Writable;
use packet_macros::LoginPacket;
use std::hash::Hash;
diff --git a/azalea-protocol/src/write.rs b/azalea-protocol/src/write.rs
index 345829c5..9291681c 100755
--- a/azalea-protocol/src/write.rs
+++ b/azalea-protocol/src/write.rs
@@ -2,10 +2,7 @@ use crate::{mc_buf::Writable, packets::ProtocolPacket, read::MAXIMUM_UNCOMPRESSE
use async_compression::tokio::bufread::ZlibEncoder;
use azalea_crypto::Aes128CfbEnc;
use std::fmt::Debug;
-use tokio::{
- io::{AsyncReadExt, AsyncWrite, AsyncWriteExt},
- net::TcpStream,
-};
+use tokio::io::{AsyncReadExt, AsyncWrite, AsyncWriteExt};
fn frame_prepender(data: &mut Vec<u8>) -> Result<Vec<u8>, String> {
let mut buf = Vec::new();