Skip to content

Commit

Permalink
Some Renames
Browse files Browse the repository at this point in the history
  • Loading branch information
Snowiiii committed Feb 5, 2025
1 parent 12866bc commit 3d789f7
Show file tree
Hide file tree
Showing 26 changed files with 85 additions and 79 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The Documentation of Pumpkin can be found at <https://pumpkinmc.org/>
### Coding Guidelines

Things need to be done before this Pull Request can be merged. Your CI also checks most of them automatically and fill fail if something is not fulfilled
Note: Pumpkin's clippy settings are relatively strict, this can be may frustrating but is necessary so the code says clean and conssistent
Note: Pumpkin's clippy settings are relatively strict, this can be may frustrating but is necessary so the code says clean and consistent
**Basic**

- **Title:** Use a concise and informative title that clearly communicates the purpose of the PR. Anyone reviewing the PR should quickly understand the changes being proposed.
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ rayon = "1.10"
parking_lot = { version = "0.12", features = ["send_guard"] }
crossbeam = "0.8"

uuid = { version = "1.12", features = ["serde", "v3", "v4"] }
derive_more = { version = "1.0", features = ["full"] }
uuid = { version = "1.13", features = ["serde", "v3", "v4"] }
derive_more = { version = "2.0", features = ["full"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

Expand Down
4 changes: 2 additions & 2 deletions pumpkin-config/src/networking/compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ pub struct CompressionConfig {
/// Whether compression is enabled
pub enabled: bool,
#[serde(flatten)]
pub compression_info: CompressionInfo,
pub info: CompressionInfo,
}

impl Default for CompressionConfig {
fn default() -> Self {
Self {
enabled: true,
compression_info: Default::default(),
info: Default::default(),
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions pumpkin-config/src/networking/rcon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ impl Default for RCONConfig {
#[serde(default)]
pub struct RCONLogging {
/// Whether successful RCON logins should be logged.
pub log_logged_successfully: bool,
pub logged_successfully: bool,
/// Whether failed RCON login attempts with incorrect passwords should be logged.
pub log_wrong_password: bool,
pub wrong_password: bool,
/// Whether all RCON commands, regardless of success or failure, should be logged.
pub log_commands: bool,
pub commands: bool,
/// Whether RCON quit commands should be logged.
pub log_quit: bool,
pub quit: bool,
}

impl Default for RCONLogging {
fn default() -> Self {
Self {
log_logged_successfully: true,
log_wrong_password: true,
log_commands: true,
log_quit: true,
logged_successfully: true,
wrong_password: true,
commands: true,
quit: true,
}
}
}
12 changes: 6 additions & 6 deletions pumpkin-config/src/resource_pack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ use serde::{Deserialize, Serialize};
pub struct ResourcePackConfig {
pub enabled: bool,
/// The path to the resource pack.
pub resource_pack_url: String,
pub url: String,
/// The SHA1 hash (40) of the resource pack.
pub resource_pack_sha1: String,
pub sha1: String,
/// Custom prompt Text component, Leave blank for none
pub prompt_message: String,
pub message: String,
/// Will force the Player to accept the resource pack
pub force: bool,
}

impl ResourcePackConfig {
pub fn validate(&self) {
assert_eq!(
!self.resource_pack_url.is_empty(),
!self.resource_pack_sha1.is_empty(),
!self.url.is_empty(),
!self.sha1.is_empty(),
"Resource Pack path or Sha1 hash is missing"
);
assert!(
self.resource_pack_sha1.len() <= 40,
self.sha1.len() <= 40,
"Resource pack sha1 hash is too long (max. 40)"
)
}
Expand Down
10 changes: 5 additions & 5 deletions pumpkin-protocol/src/bytebuf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub trait ByteBuf: Buf {

fn try_get_var_long(&mut self) -> Result<VarLong, ReadingError>;

fn try_get_identifer(&mut self) -> Result<Identifier, ReadingError>;
fn try_get_identifier(&mut self) -> Result<Identifier, ReadingError>;

fn try_get_string(&mut self) -> Result<String, ReadingError>;

Expand Down Expand Up @@ -170,12 +170,12 @@ impl<T: Buf> ByteBuf for T {
self.try_copy_to_bytes(bits.div_ceil(8))
}

fn try_get_identifer(&mut self) -> Result<Identifier, ReadingError> {
fn try_get_identifier(&mut self) -> Result<Identifier, ReadingError> {
match Identifier::decode(self) {
Ok(identifer) => Ok(identifer),
Ok(identifier) => Ok(identifier),
Err(error) => match error {
DecodeError::Incomplete => Err(ReadingError::Incomplete("identifer".to_string())),
DecodeError::TooLarge => Err(ReadingError::TooLarge("identifer".to_string())),
DecodeError::Incomplete => Err(ReadingError::Incomplete("identifier".to_string())),
DecodeError::TooLarge => Err(ReadingError::TooLarge("identifier".to_string())),
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/client/play/take_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use serde::Serialize;
pub struct CTakeItemEntity {
/// The Entity ID of the Item Entity
entity_id: VarInt,
/// The Entity ID of the Entitiy who is collecting the Item
/// The Entity ID of the Entity who is collecting the Item
collector_entity_id: VarInt,
/// The Number of items in the Stack
stack_amount: VarInt,
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/client/status/ping_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use serde::Serialize;
#[derive(Serialize)]
#[client_packet(STATUS_PONG_RESPONSE)]
pub struct CPingResponse {
payload: i64, // must responde with the same as in `SPingRequest`
payload: i64, // must respond with the same as in `SPingRequest`
}

impl CPingResponse {
Expand Down
10 changes: 5 additions & 5 deletions pumpkin-protocol/src/codec/identifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl Identifier {
}
}
impl Codec<Self> for Identifier {
/// The maximum number of bytes a `Identifer` is the same as for a normal String.
/// The maximum number of bytes a `Identifier` is the same as for a normal String.
const MAX_SIZE: NonZeroUsize = unsafe { NonZeroUsize::new_unchecked(i16::MAX as usize) };

fn written_size(&self) -> usize {
Expand All @@ -34,10 +34,10 @@ impl Codec<Self> for Identifier {
}

fn decode(read: &mut impl Buf) -> Result<Self, DecodeError> {
let identifer = read
let identifier = read
.try_get_string_len(Self::MAX_SIZE.get())
.map_err(|_| DecodeError::Incomplete)?;
match identifer.split_once(":") {
match identifier.split_once(":") {
Some((namespace, path)) => Ok(Identifier {
namespace: namespace.to_string(),
path: path.to_string(),
Expand Down Expand Up @@ -77,11 +77,11 @@ impl<'de> Deserialize<'de> for Identifier {
self.visit_str(&v)
}

fn visit_str<E>(self, identifer: &str) -> Result<Self::Value, E>
fn visit_str<E>(self, identifier: &str) -> Result<Self::Value, E>
where
E: serde::de::Error,
{
match identifer.split_once(":") {
match identifier.split_once(":") {
Some((namespace, path)) => Ok(Identifier {
namespace: namespace.to_string(),
path: path.to_string(),
Expand Down
6 changes: 3 additions & 3 deletions pumpkin-protocol/src/packet_decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use crate::{

type Cipher = cfb8::Decryptor<aes::Aes128>;

// Decoder: Client -> Server
// Supports ZLib decoding/decompression
// Supports Aes128 Encryption
/// Decoder: Client -> Server
/// Supports ZLib decoding/decompression
/// Supports Aes128 Encryption
#[derive(Default)]
pub struct PacketDecoder {
buf: BytesMut,
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/server/config/cookie_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const MAX_COOKIE_LENGTH: usize = 5120;

impl ServerPacket for SConfigCookieResponse {
fn read(bytebuf: &mut impl Buf) -> Result<Self, ReadingError> {
let key = bytebuf.try_get_identifer()?;
let key = bytebuf.try_get_identifier()?;
let has_payload = bytebuf.try_get_bool()?;

if !has_payload {
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/server/config/plugin_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct SPluginMessage {
impl ServerPacket for SPluginMessage {
fn read(bytebuf: &mut impl Buf) -> Result<Self, ReadingError> {
Ok(Self {
channel: bytebuf.try_get_identifer()?,
channel: bytebuf.try_get_identifier()?,
data: bytebuf.try_copy_to_bytes_len(bytebuf.remaining(), MAX_PAYLOAD_SIZE)?,
})
}
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/server/login/cookie_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const MAX_COOKIE_LENGTH: usize = 5120;

impl ServerPacket for SLoginCookieResponse {
fn read(bytebuf: &mut impl Buf) -> Result<Self, ReadingError> {
let key = bytebuf.try_get_identifer()?;
let key = bytebuf.try_get_identifier()?;
let has_payload = bytebuf.try_get_bool()?;

if !has_payload {
Expand Down
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/server/play/cookie_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const MAX_COOKIE_LENGTH: usize = 5120;

impl ServerPacket for SCookieResponse {
fn read(bytebuf: &mut impl Buf) -> Result<Self, ReadingError> {
let key = bytebuf.try_get_identifer()?;
let key = bytebuf.try_get_identifier()?;
let has_payload = bytebuf.try_get_bool()?;

if !has_payload {
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions pumpkin/src/entity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ pub mod mob;
pub mod player;
pub mod projectile;

mod combat;

pub type EntityId = i32;

#[async_trait]
Expand Down
11 changes: 6 additions & 5 deletions pumpkin/src/entity/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ use pumpkin_world::{
};
use tokio::sync::{Mutex, Notify, RwLock};

use super::{item::ItemEntity, Entity, EntityId, NBTStorage};
use super::{
combat::{self, player_attack_sound, AttackType},
item::ItemEntity,
Entity, EntityId, NBTStorage,
};
use crate::{
command::{client_suggestions, dispatcher::CommandDispatcher},
data::op_data::OPERATOR_CONFIG,
net::{
combat::{self, player_attack_sound, AttackType},
Client, PlayerConfig,
},
net::{Client, PlayerConfig},
server::Server,
world::World,
};
Expand Down
1 change: 0 additions & 1 deletion pumpkin/src/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ use tokio::sync::Mutex;
use thiserror::Error;
use uuid::Uuid;
mod authentication;
pub mod combat;
mod container;
pub mod lan_broadcast;
mod packet;
Expand Down
19 changes: 6 additions & 13 deletions pumpkin/src/net/packet/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,7 @@ impl Client {
}

async fn enable_compression(&self) {
let compression = ADVANCED_CONFIG
.networking
.packet_compression
.compression_info
.clone();
let compression = ADVANCED_CONFIG.networking.packet_compression.info.clone();
self.send_packet(&CSetCompression::new(compression.threshold.into()))
.await;
self.set_compression(Some(compression)).await;
Expand Down Expand Up @@ -334,17 +330,14 @@ impl Client {
let resource_config = &ADVANCED_CONFIG.resource_pack;
if resource_config.enabled {
let resource_pack = CConfigAddResourcePack::new(
Uuid::new_v3(
&uuid::Uuid::NAMESPACE_DNS,
resource_config.resource_pack_url.as_bytes(),
),
&resource_config.resource_pack_url,
&resource_config.resource_pack_sha1,
Uuid::new_v3(&uuid::Uuid::NAMESPACE_DNS, resource_config.url.as_bytes()),
&resource_config.url,
&resource_config.sha1,
resource_config.force,
if resource_config.prompt_message.is_empty() {
if resource_config.message.is_empty() {
None
} else {
Some(TextComponent::text(&resource_config.prompt_message))
Some(TextComponent::text(&resource_config.message))
},
);

Expand Down
16 changes: 8 additions & 8 deletions pumpkin/src/net/packet/play.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
entity::player::{ChatMode, Hand, Player},
error::PumpkinError,
server::Server,
world::player_chunker,
world::chunker,
};
use pumpkin_config::ADVANCED_CONFIG;
use pumpkin_data::entity::{EntityPose, EntityType};
Expand Down Expand Up @@ -204,7 +204,7 @@ impl Player {
)
.await;
}
player_chunker::update_position(self).await;
chunker::update_position(self).await;
}

pub async fn handle_position_rotation(self: &Arc<Self>, packet: SPlayerPositionRotation) {
Expand Down Expand Up @@ -296,7 +296,7 @@ impl Player {
)
.await;
}
player_chunker::update_position(self).await;
chunker::update_position(self).await;
}

pub async fn handle_rotation(&self, rotation: SPlayerRotation) {
Expand Down Expand Up @@ -614,9 +614,9 @@ impl Player {
return;
}

let (update_skin, update_watched) = {
let (update_settings, update_watched) = {
let mut config = self.config.lock().await;
let update_skin = config.main_hand != main_hand
let update_settings = config.main_hand != main_hand
|| config.skin_parts != client_information.skin_parts;

let old_view_distance = config.view_distance;
Expand Down Expand Up @@ -649,14 +649,14 @@ impl Player {
text_filtering: client_information.text_filtering,
server_listing: client_information.server_listing,
};
(update_skin, update_watched)
(update_settings, update_watched)
};

if update_watched {
player_chunker::update_position(self).await;
chunker::update_position(self).await;
}

if update_skin {
if update_settings {
log::debug!(
"Player {} ({}) updated their skin.",
self.gameprofile.name,
Expand Down
6 changes: 3 additions & 3 deletions pumpkin/src/net/rcon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ impl RCONClient {
if packet.get_body() == password {
self.send(ClientboundPacket::AuthResponse, packet.get_id(), "")
.await?;
if config.logging.log_logged_successfully {
if config.logging.logged_successfully {
log::info!("RCON ({}): Client logged in successfully", self.address);
}
self.logged_in = true;
} else {
if config.logging.log_wrong_password {
if config.logging.wrong_password {
log::info!("RCON ({}): Client has tried wrong password", self.address);
}
self.send(ClientboundPacket::AuthResponse, -1, "").await?;
Expand All @@ -121,7 +121,7 @@ impl RCONClient {

let output = output.lock().await;
for line in output.iter() {
if config.logging.log_commands {
if config.logging.commands {
log::info!("RCON ({}): {}", self.address, line);
}
self.send(ClientboundPacket::Output, packet.get_id(), line)
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 3d789f7

Please sign in to comment.