fix: all clippy warns

This commit is contained in:
Snowiiii 2024-08-04 00:40:27 +02:00
parent ae69bbc7f1
commit 19af3618cb
13 changed files with 44 additions and 48 deletions

View File

@ -1,13 +1,15 @@
use crate::{bytebuf::ByteBuffer, ClientPacket, KnownPack, VarInt};
use crate::{bytebuf::ByteBuffer, ClientPacket, Identifier, KnownPack, VarInt};
pub struct CCookieRequest {
// TODO
key: Identifier,
}
impl ClientPacket for CCookieRequest {
const PACKET_ID: VarInt = 0x00;
fn write(&self, bytebuf: &mut ByteBuffer) {}
fn write(&self, bytebuf: &mut ByteBuffer) {
bytebuf.put_string(&self.key);
}
}
pub struct CPluginMessage<'a> {
@ -115,7 +117,7 @@ impl<'a> ClientPacket for CRegistryData<'a> {
fn write(&self, bytebuf: &mut ByteBuffer) {
bytebuf.put_string(self.registry_id);
bytebuf.put_list::<RegistryEntry>(self.entries, |p, v| {
p.put_string(&v.entry_id);
p.put_string(v.entry_id);
p.put_bool(!v.data.is_empty());
p.put_slice(&v.data);
});

View File

@ -58,25 +58,24 @@ pub struct CSetCompression {
threshold: VarInt,
}
pub struct CLoginSuccess {
pub struct CLoginSuccess<'a> {
pub uuid: uuid::Uuid,
pub username: String, // 16
pub num_of_props: VarInt,
// pub property: Property,
pub properties: &'a [Property],
pub strict_error_handling: bool,
}
impl CLoginSuccess {
impl<'a> CLoginSuccess<'a> {
pub fn new(
uuid: uuid::Uuid,
username: String,
num_of_props: VarInt,
properties: &'a [Property],
strict_error_handling: bool,
) -> Self {
Self {
uuid,
username,
num_of_props,
properties,
strict_error_handling,
}
}
@ -89,14 +88,18 @@ pub struct Property {
signature: Option<String>,
}
impl ClientPacket for CLoginSuccess {
impl<'a> ClientPacket for CLoginSuccess<'a> {
const PACKET_ID: VarInt = 0x02;
fn write(&self, bytebuf: &mut ByteBuffer) {
bytebuf.put_uuid(self.uuid);
bytebuf.put_string(&self.username);
bytebuf.put_var_int(self.num_of_props);
// Todo
bytebuf.put_list::<Property>(self.properties, |p, v| {
p.put_string(&v.name);
p.put_string(&v.value);
p.put_bool(v.is_signed);
p.put_option(&v.signature, |p, v| p.put_string(v.as_str()))
});
bytebuf.put_bool(self.strict_error_handling);
}
}

View File

@ -248,6 +248,7 @@ pub struct CChunkDataUpdateLight {
}
impl CChunkDataUpdateLight {
#[allow(clippy::too_many_arguments)]
pub fn new(
chunk_x: i32,
chunk_y: i32,

View File

@ -55,7 +55,7 @@ impl ServerPacket for SAcknowledgeFinishConfig {
}
pub struct SKnownPacks {
known_pack_count: VarInt,
pub known_pack_count: VarInt,
// known_packs: &'a [KnownPack]
}

View File

@ -41,9 +41,9 @@ impl ServerPacket for SEncryptionResponse {
}
pub struct SLoginPluginResponse<'a> {
message_id: VarInt,
successful: bool,
data: Option<&'a [u8]>,
pub message_id: VarInt,
pub successful: bool,
pub data: Option<&'a [u8]>,
}
impl<'a> ServerPacket for SLoginPluginResponse<'a> {

View File

@ -1,13 +1 @@
use serde::Serialize;
#[derive(Debug, Clone, Serialize)]
pub struct ChatType {
chat: Decoration,
narration: Decoration,
}
#[derive(Debug, Clone, Serialize)]
struct Decoration {
translation_key: String,
// style: Option<>
parameters: Vec<String>,
}

View File

@ -67,7 +67,7 @@ pub(super) fn entires() -> Vec<RegistryEntry<'static>> {
let items: Vec<_> = NAMES
.iter()
.map(|name| RegistryEntry {
entry_id: (*name).into(),
entry_id: name,
data: fastnbt::to_bytes_with_opts(
&DamageType {
exhaustion: 0.1,

View File

@ -1,4 +1,4 @@
use fastnbt::{nbt, SerOpts};
use fastnbt::nbt;
pub const BLOCKS_AND_BIOMES: [u8; 2000] = [0x80; 2000];
pub const SKY_LIGHT_ARRAYS: [FixedArray<u8, 2048>; 26] = [FixedArray([0xff; 2048]); 26];
@ -11,6 +11,12 @@ pub struct TestChunk {
pub heightmap: Vec<u8>,
}
impl Default for TestChunk {
fn default() -> Self {
Self::new()
}
}
impl TestChunk {
pub fn new() -> Self {
let bytes = fastnbt::to_bytes(&nbt!({"MOTION_BLOCKING": [L; 123, 256]})).unwrap();

View File

@ -1,6 +1,6 @@
use std::{fs::File, path::Path};
use fastanvil::{complete, Chunk, Region};
use fastanvil::Region;
pub mod chunk;

View File

@ -109,7 +109,7 @@ impl ClientPacketProcessor for Client {
if let Some(uuid) = self.uuid {
if let Some(name) = &self.name {
let packet = CLoginSuccess::new(uuid, name.clone(), 0, false);
let packet = CLoginSuccess::new(uuid, name.clone(), &[], false); // todo
self.send_packet(packet)
.unwrap_or_else(|e| self.kick(&e.to_string()));
} else {

View File

@ -35,14 +35,14 @@ pub mod player_packet;
use client_packet::ClientPacketProcessor;
pub struct PlayerConfig {
locale: String, // 16
view_distance: i8,
chat_mode: ChatMode,
chat_colors: bool,
skin_parts: u8,
main_hand: Hand,
text_filtering: bool,
server_listing: bool,
pub locale: String, // 16
pub view_distance: i8,
pub chat_mode: ChatMode,
pub chat_colors: bool,
pub skin_parts: u8,
pub main_hand: Hand,
pub text_filtering: bool,
pub server_listing: bool,
}
pub struct Client {

View File

@ -1,6 +1,6 @@
use pumpkin_protocol::server::play::SConfirmTeleport;
use crate::{entity::player::Player, server::Server};
use crate::server::Server;
use super::Client;

View File

@ -1,6 +1,5 @@
use std::{
io::Cursor,
rc::Rc,
sync::atomic::{AtomicI32, Ordering},
};
@ -9,14 +8,11 @@ use mio::{event::Event, Poll};
use pumpkin_protocol::{
client::{
config::CPluginMessage,
play::{CChunkDataUpdateLight, CGameEvent, CLogin, CSyncPlayerPostion, SkyLight},
play::{CChunkDataUpdateLight, CGameEvent, CLogin, CSyncPlayerPostion},
},
BitSet, PacketError, Players, Sample, StatusResponse, VarInt, VarInt32, Version,
};
use pumpkin_world::{
chunk::{TestChunk, SKY_LIGHT_ARRAYS},
World,
};
use pumpkin_world::chunk::TestChunk;
use rsa::{rand_core::OsRng, traits::PublicKeyParts, RsaPrivateKey, RsaPublicKey};
use serde::{Deserialize, Serialize};