0
0
mirror of https://github.com/Pumpkin-MC/Pumpkin synced 2025-04-12 22:13:03 +00:00

Fix: Clippy 1.83

This commit is contained in:
Snowiiii
2024-11-28 21:52:55 +01:00
parent 267225c01d
commit 5efa881090
33 changed files with 55 additions and 55 deletions

@ -46,7 +46,7 @@ impl<'de> Deserialize<'de> for WorldPosition {
D: serde::Deserializer<'de>,
{
struct Visitor;
impl<'a> serde::de::Visitor<'a> for Visitor {
impl serde::de::Visitor<'_> for Visitor {
type Value = WorldPosition;
fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
formatter.write_str("An i64 int")

@ -85,7 +85,7 @@ impl<'a> TextComponent<'a> {
}
}
impl<'a> serde::Serialize for TextComponent<'a> {
impl serde::Serialize for TextComponent<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,

@ -57,7 +57,7 @@ where
T::deserialize(&mut deserializer)
}
impl<'de, 'a, T: Buf> de::Deserializer<'de> for &'a mut Deserializer<'de, T> {
impl<'de, T: Buf> de::Deserializer<'de> for &mut Deserializer<'de, T> {
type Error = Error;
forward_to_deserialize_any!(i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 seq char str string bytes byte_buf tuple tuple_struct enum ignored_any unit unit_struct option newtype_struct);
@ -163,7 +163,7 @@ struct CompoundAccess<'a, 'de: 'a, T: Buf> {
de: &'a mut Deserializer<'de, T>,
}
impl<'de, 'a, T: Buf> MapAccess<'de> for CompoundAccess<'a, 'de, T> {
impl<'de, T: Buf> MapAccess<'de> for CompoundAccess<'_, 'de, T> {
type Error = Error;
fn next_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>>
@ -194,7 +194,7 @@ struct ListAccess<'a, 'de: 'a, T: Buf> {
list_type: u8,
}
impl<'a, 'de, T: Buf> SeqAccess<'de> for ListAccess<'a, 'de, T> {
impl<'de, T: Buf> SeqAccess<'de> for ListAccess<'_, 'de, T> {
type Error = Error;
fn next_element_seed<E>(&mut self, seed: E) -> Result<Option<E::Value>>

@ -100,7 +100,7 @@ where
Ok(())
}
impl<'a> ser::Serializer for &'a mut Serializer {
impl ser::Serializer for &mut Serializer {
type Ok = ();
type Error = Error;
@ -368,7 +368,7 @@ impl<'a> ser::Serializer for &'a mut Serializer {
}
}
impl<'a> ser::SerializeSeq for &'a mut Serializer {
impl ser::SerializeSeq for &mut Serializer {
type Ok = ();
type Error = Error;
@ -386,7 +386,7 @@ impl<'a> ser::SerializeSeq for &'a mut Serializer {
}
}
impl<'a> ser::SerializeStruct for &'a mut Serializer {
impl ser::SerializeStruct for &mut Serializer {
type Ok = ();
type Error = Error;
@ -404,7 +404,7 @@ impl<'a> ser::SerializeStruct for &'a mut Serializer {
}
}
impl<'a> ser::SerializeMap for &'a mut Serializer {
impl ser::SerializeMap for &mut Serializer {
type Ok = ();
type Error = Error;

@ -31,7 +31,7 @@ impl<'a> Deserializer<'a> {
}
}
impl<'a, 'de> de::Deserializer<'de> for Deserializer<'a> {
impl<'de> de::Deserializer<'de> for Deserializer<'_> {
type Error = DeserializerError;
fn deserialize_any<V>(self, _visitor: V) -> Result<V::Value, Self::Error>

@ -8,7 +8,7 @@ use crate::{BitSet, ClientPacket, ServerPacket, VarInt, VarIntType, VarLong};
use super::{deserializer, serializer, ByteBuffer, DeserializerError};
impl<'a> Serialize for BitSet<'a> {
impl Serialize for BitSet<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,

@ -56,7 +56,7 @@ impl ser::Error for SerializerError {
// Structs are ignored
// Iterables' values are written in order, but NO information (e.g. size) about the
// iterable itself is written (list sizes should be a seperate field)
impl<'a> ser::Serializer for &'a mut Serializer {
impl ser::Serializer for &mut Serializer {
type Ok = ();
type Error = SerializerError;
@ -226,7 +226,7 @@ impl<'a> ser::Serializer for &'a mut Serializer {
}
}
impl<'a> ser::SerializeSeq for &'a mut Serializer {
impl ser::SerializeSeq for &mut Serializer {
// Must match the `Ok` type of the serializer.
type Ok = ();
// Must match the `Error` type of the serializer.
@ -246,7 +246,7 @@ impl<'a> ser::SerializeSeq for &'a mut Serializer {
}
}
impl<'a> ser::SerializeTuple for &'a mut Serializer {
impl ser::SerializeTuple for &mut Serializer {
type Ok = ();
type Error = SerializerError;
@ -263,7 +263,7 @@ impl<'a> ser::SerializeTuple for &'a mut Serializer {
}
// Same thing but for tuple structs.
impl<'a> ser::SerializeTupleStruct for &'a mut Serializer {
impl ser::SerializeTupleStruct for &mut Serializer {
type Ok = ();
type Error = SerializerError;
@ -288,7 +288,7 @@ impl<'a> ser::SerializeTupleStruct for &'a mut Serializer {
//
// So the `end` method in this impl is responsible for closing both the `]` and
// the `}`.
impl<'a> ser::SerializeTupleVariant for &'a mut Serializer {
impl ser::SerializeTupleVariant for &mut Serializer {
type Ok = ();
type Error = SerializerError;
@ -312,7 +312,7 @@ impl<'a> ser::SerializeTupleVariant for &'a mut Serializer {
// `serialize_entry` method allows serializers to optimize for the case where
// key and value are both available simultaneously. In JSON it doesn't make a
// difference so the default behavior for `serialize_entry` is fine.
impl<'a> ser::SerializeMap for &'a mut Serializer {
impl ser::SerializeMap for &mut Serializer {
type Ok = ();
type Error = SerializerError;
@ -348,7 +348,7 @@ impl<'a> ser::SerializeMap for &'a mut Serializer {
// Structs are like maps in which the keys are constrained to be compile-time
// constant strings.
impl<'a> ser::SerializeStruct for &'a mut Serializer {
impl ser::SerializeStruct for &mut Serializer {
type Ok = ();
type Error = SerializerError;
@ -371,7 +371,7 @@ impl<'a> ser::SerializeStruct for &'a mut Serializer {
// Similar to `SerializeTupleVariant`, here the `end` method is responsible for
// closing both of the curly braces opened by `serialize_struct_variant`.
impl<'a> ser::SerializeStructVariant for &'a mut Serializer {
impl ser::SerializeStructVariant for &mut Serializer {
type Ok = ();
type Error = SerializerError;

@ -13,7 +13,7 @@ impl<'a> CKnownPacks<'a> {
}
}
impl<'a> ClientPacket for CKnownPacks<'a> {
impl ClientPacket for CKnownPacks<'_> {
fn write(&self, bytebuf: &mut ByteBuffer) {
bytebuf.put_list::<KnownPack>(self.known_packs, |p, v| {
p.put_string(v.namespace);

@ -23,7 +23,7 @@ pub struct RegistryEntry<'a> {
pub data: BytesMut,
}
impl<'a> ClientPacket for CRegistryData<'a> {
impl ClientPacket for CRegistryData<'_> {
fn write(&self, bytebuf: &mut ByteBuffer) {
bytebuf.put_string(self.registry_id);
bytebuf.put_list::<RegistryEntry>(self.entries, |p, v| {

@ -21,7 +21,7 @@ pub enum Label<'a> {
TextComponent(TextComponent<'a>),
}
impl<'a> Serialize for Label<'a> {
impl Serialize for Label<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,

@ -19,7 +19,7 @@ impl<'a> CLoginSuccess<'a> {
}
}
impl<'a> ClientPacket for CLoginSuccess<'a> {
impl ClientPacket for CLoginSuccess<'_> {
fn write(&self, bytebuf: &mut ByteBuffer) {
bytebuf.put_uuid(self.uuid);
bytebuf.put_string(self.username);

@ -15,7 +15,7 @@ impl<'a> CBossEvent<'a> {
}
}
impl<'a> ClientPacket for CBossEvent<'a> {
impl ClientPacket for CBossEvent<'_> {
fn write(&self, bytebuf: &mut ByteBuffer) {
bytebuf.put_uuid(&self.uuid);
let action = &self.action;

@ -7,7 +7,7 @@ use pumpkin_world::{chunk::ChunkData, DIRECT_PALETTE_BITS};
#[client_packet("play:level_chunk_with_light")]
pub struct CChunkData<'a>(pub &'a ChunkData);
impl<'a> ClientPacket for CChunkData<'a> {
impl ClientPacket for CChunkData<'_> {
fn write(&self, buf: &mut crate::bytebuf::ByteBuffer) {
// Chunk X
buf.put_i32(self.0.position.x);

@ -27,7 +27,7 @@ impl<'a> CCommandSuggestions<'a> {
}
}
impl<'a> ClientPacket for CCommandSuggestions<'a> {
impl ClientPacket for CCommandSuggestions<'_> {
fn write(&self, bytebuf: &mut crate::bytebuf::ByteBuffer) {
bytebuf.put_var_int(&self.id);
bytebuf.put_var_int(&self.start);

@ -17,7 +17,7 @@ impl<'a> CCommands<'a> {
}
}
impl<'a> ClientPacket for CCommands<'a> {
impl ClientPacket for CCommands<'_> {
fn write(&self, bytebuf: &mut ByteBuffer) {
bytebuf.put_list(&self.nodes, |bytebuf, node: &ProtoNode| {
node.write_to(bytebuf)
@ -46,7 +46,7 @@ pub enum ProtoNodeType<'a> {
},
}
impl<'a> ProtoNode<'a> {
impl ProtoNode<'_> {
const FLAG_IS_EXECUTABLE: u8 = 4;
const FLAG_HAS_REDIRECT: u8 = 8;
const FLAG_HAS_SUGGESTION_TYPE: u8 = 16;
@ -181,7 +181,7 @@ pub enum ProtoCmdArgParser<'a> {
Uuid,
}
impl<'a> ProtoCmdArgParser<'a> {
impl ProtoCmdArgParser<'_> {
pub const ENTITY_FLAG_ONLY_SINGLE: u8 = 1;
pub const ENTITY_FLAG_PLAYERS_ONLY: u8 = 2;

@ -21,7 +21,7 @@ impl<'a> CPlayerInfoUpdate<'a> {
}
}
impl<'a> ClientPacket for CPlayerInfoUpdate<'a> {
impl ClientPacket for CPlayerInfoUpdate<'_> {
fn write(&self, bytebuf: &mut ByteBuffer) {
bytebuf.put_i8(self.actions);
bytebuf.put_list::<Player>(self.players, |p, v| {

@ -21,7 +21,7 @@ pub enum Label<'a> {
TextComponent(TextComponent<'a>),
}
impl<'a> Serialize for Label<'a> {
impl Serialize for Label<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,

@ -41,7 +41,7 @@ impl<'a> CSyncPlayerPosition<'a> {
}
}
impl<'a> ClientPacket for CSyncPlayerPosition<'a> {
impl ClientPacket for CSyncPlayerPosition<'_> {
fn write(&self, bytebuf: &mut crate::bytebuf::ByteBuffer) {
bytebuf.put_var_int(&self.teleport_id);
bytebuf.put_f64(self.x);

@ -30,7 +30,7 @@ impl<'a> CUpdateObjectives<'a> {
}
}
impl<'a> ClientPacket for CUpdateObjectives<'a> {
impl ClientPacket for CUpdateObjectives<'_> {
fn write(&self, bytebuf: &mut crate::bytebuf::ByteBuffer) {
bytebuf.put_string(self.objective_name);
bytebuf.put_u8(self.mode);

@ -95,7 +95,7 @@ pub mod ingredients {
}
struct IngredientTypeVisitor;
impl<'de> Visitor<'de> for IngredientTypeVisitor {
impl Visitor<'_> for IngredientTypeVisitor {
type Value = IngredientType;
fn expecting(&self, formatter: &mut Formatter) -> std::fmt::Result {
write!(formatter, "valid item type")

@ -82,7 +82,7 @@ impl<'de> Deserialize<'de> for TagType {
D: Deserializer<'de>,
{
struct TagVisitor;
impl<'de> Visitor<'de> for TagVisitor {
impl Visitor<'_> for TagVisitor {
type Value = TagType;
fn expecting(&self, formatter: &mut Formatter) -> std::fmt::Result {
write!(formatter, "valid tag")

@ -145,8 +145,9 @@ impl ChunkReader for AnvilChunkReader {
// TODO: check checksum to make sure chunk is not corrupted
let header = file_buf.drain(0..5).collect_vec();
let compression = Compression::from_byte(header[4])
.ok_or_else(|| ChunkReadingError::Compression(CompressionError::UnknownCompression))?;
let compression = Compression::from_byte(header[4]).ok_or(
ChunkReadingError::Compression(CompressionError::UnknownCompression),
)?;
let size = u32::from_be_bytes(header[..4].try_into().unwrap());

@ -66,7 +66,7 @@ impl<'a> BlendDensityFunction<'a> {
}
}
impl<'a> BlendDensityFunction<'a> {
impl BlendDensityFunction<'_> {
fn apply_density(&self, pos: &NoisePos, density: f64) -> f64 {
pos.get_blender().apply_blend_density(pos, density)
}

@ -875,7 +875,7 @@ pub struct Unused<'a> {
_x: &'a str,
}
impl<'a> NoisePosImpl for Unused<'a> {
impl NoisePosImpl for Unused<'_> {
fn x(&self) -> i32 {
todo!()
}

@ -65,7 +65,7 @@ pub struct UnaryFunction<'a> {
}
impl<'a> UnaryFunction<'a> {
pub(crate) fn create(action: UnaryType, input: Arc<DensityFunction<'a>>) -> UnaryFunction {
pub(crate) fn create(action: UnaryType, input: Arc<DensityFunction<'a>>) -> UnaryFunction<'a> {
let base_min = input.min();
let new_min = Self::internal_apply(&action, base_min);
let new_max = Self::internal_apply(&action, input.max());

@ -70,7 +70,7 @@ pub struct BuiltInNoiseParams<'a> {
nether_state_selector: DoublePerlinNoiseParameters<'a>,
}
impl<'a> BuiltInNoiseParams<'a> {
impl BuiltInNoiseParams<'_> {
pub fn new() -> Self {
Self {
temperature: DoublePerlinNoiseParameters::new(

@ -57,7 +57,7 @@ where
}
}
impl<'a, T: ToFromNumber> FindArg<'a> for BoundedNumArgumentConsumer<T> {
impl<T: ToFromNumber> FindArg<'_> for BoundedNumArgumentConsumer<T> {
type Data = Result<T, NotInBounds>;
fn find_arg(args: &super::ConsumedArgs, name: &str) -> Result<Self::Data, CommandError> {

@ -32,7 +32,7 @@ pub enum CommandSender<'a> {
Player(Arc<Player>),
}
impl<'a> fmt::Display for CommandSender<'a> {
impl fmt::Display for CommandSender<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,

@ -81,7 +81,7 @@ struct TraverseAllPathsIter<'a> {
todo: VecDeque<(usize, usize)>,
}
impl<'a> Iterator for TraverseAllPathsIter<'a> {
impl Iterator for TraverseAllPathsIter<'_> {
type Item = Vec<usize>;
fn next(&mut self) -> Option<Self::Item> {

@ -7,7 +7,7 @@ trait IsVisible {
fn is_visible(&self) -> bool;
}
impl<'a> IsVisible for Node<'a> {
impl IsVisible for Node<'_> {
fn is_visible(&self) -> bool {
matches!(
self.node_type,
@ -16,7 +16,7 @@ impl<'a> IsVisible for Node<'a> {
}
}
impl<'a> Display for Node<'a> {
impl Display for Node<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self.node_type {
NodeType::Literal { string } => {
@ -50,7 +50,7 @@ fn flatten_require_nodes(nodes: &[Node], children: &[usize]) -> Vec<usize> {
new_children
}
impl<'a> Display for CommandTree<'a> {
impl Display for CommandTree<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_char('/')?;
f.write_str(self.names[0])?;

@ -1,3 +1,6 @@
/// Proxy implementation for Velocity <https://papermc.io/software/velocity> by `PaperMC`
/// Sadly `PaperMC` does not care about 3th Parties providing support for Velocity, There is no documentation.
/// I had to understand the Code logic by looking at `PaperMC`'s Velocity implementation: <https://github.com/PaperMC/Paper/blob/master/patches/server/0731-Add-Velocity-IP-Forwarding-Support.patch>
use std::net::{IpAddr, SocketAddr};
use bytes::{BufMut, BytesMut};
@ -13,10 +16,6 @@ use thiserror::Error;
use crate::client::{authentication::GameProfile, Client};
/// Proxy implementation for Velocity <https://papermc.io/software/velocity> by `PaperMC`
/// Sadly `PaperMC` does not care about 3th Parties providing support for Velocity, There is no documentation.
/// I had to understand the Code logic by looking at `PaperMC`'s Velocity implementation: <https://github.com/PaperMC/Paper/blob/master/patches/server/0731-Add-Velocity-IP-Forwarding-Support.patch>
type HmacSha256 = Hmac<Sha256>;
const MAX_SUPPORTED_FORWARDING_VERSION: u8 = 4;

@ -41,7 +41,7 @@ impl KeyStore {
server_id: &'a str,
verification_token: &'a [u8; 4],
should_authenticate: bool,
) -> CEncryptionRequest<'_> {
) -> CEncryptionRequest<'a> {
CEncryptionRequest::new(
server_id,
&self.public_key_der,

@ -112,7 +112,7 @@ impl Server {
}
/// Adds a new player to the server.
///
/// This function takes an `Arc<Client>` representing the connected client and performs the following actions:
///
/// 1. Generates a new entity ID for the player.
@ -125,7 +125,7 @@ impl Server {
/// # Arguments
///
/// * `client`: An `Arc<Client>` representing the connected client.
///
/// # Returns
///
/// A tuple containing:
@ -301,7 +301,7 @@ impl Server {
&'a self,
verification_token: &'a [u8; 4],
should_authenticate: bool,
) -> CEncryptionRequest<'_> {
) -> CEncryptionRequest<'a> {
self.key_store
.encryption_request("", verification_token, should_authenticate)
}