mirror of
https://github.com/Pumpkin-MC/Pumpkin.git
synced 2026-08-31 08:22:33 +00:00
Inline format arguments
Looks much nicer and more readable
This commit is contained in:
@@ -29,8 +29,7 @@ impl ResourcePackConfig {
|
||||
let hash_len = self.sha1.len();
|
||||
assert!(
|
||||
hash_len == 40,
|
||||
"Resource pack SHA1 hash is the wrong length (should be 40, is {})",
|
||||
hash_len
|
||||
"Resource pack SHA1 hash is the wrong length (should be 40, is {hash_len})"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ fn const_block_name_from_block_name(block: &str) -> String {
|
||||
}
|
||||
|
||||
fn property_group_name_from_derived_name(name: &str) -> String {
|
||||
format!("{}_properties", name).to_upper_camel_case()
|
||||
format!("{name}_properties").to_upper_camel_case()
|
||||
}
|
||||
|
||||
enum PropertyType {
|
||||
@@ -1015,7 +1015,7 @@ impl GeneratedProperty {
|
||||
fn to_property(&self) -> Property {
|
||||
let enum_name = match &self.property_type {
|
||||
GeneratedPropertyType::Boolean => "boolean".to_string(),
|
||||
GeneratedPropertyType::Int { min, max } => format!("integer_{}_to_{}", min, max),
|
||||
GeneratedPropertyType::Int { min, max } => format!("integer_{min}_to_{max}"),
|
||||
GeneratedPropertyType::Enum { .. } => self.enum_name.clone(),
|
||||
};
|
||||
|
||||
@@ -1026,7 +1026,7 @@ impl GeneratedProperty {
|
||||
GeneratedPropertyType::Int { min, max } => {
|
||||
let mut values = Vec::new();
|
||||
for i in *min..=*max {
|
||||
values.push(format!("L{}", i));
|
||||
values.push(format!("L{i}"));
|
||||
}
|
||||
values
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ pub(crate) fn build() -> TokenStream {
|
||||
let data = &entry.components;
|
||||
let death_message_type = match &data.death_message_type {
|
||||
Some(msg) => {
|
||||
let msg_ident = Ident::new(&format!("{:?}", msg), proc_macro2::Span::call_site());
|
||||
let msg_ident = Ident::new(&format!("{msg:?}"), proc_macro2::Span::call_site());
|
||||
quote! { Some(DeathMessageType::#msg_ident) }
|
||||
}
|
||||
None => quote! { None },
|
||||
@@ -76,7 +76,7 @@ pub(crate) fn build() -> TokenStream {
|
||||
|
||||
let effects = match &data.effects {
|
||||
Some(msg) => {
|
||||
let msg_ident = Ident::new(&format!("{:?}", msg), proc_macro2::Span::call_site());
|
||||
let msg_ident = Ident::new(&format!("{msg:?}"), proc_macro2::Span::call_site());
|
||||
quote! { Some(DamageEffects::#msg_ident) }
|
||||
}
|
||||
None => quote! { None },
|
||||
|
||||
@@ -10,7 +10,7 @@ fn const_fluid_name_from_fluid_name(fluid: &str) -> String {
|
||||
}
|
||||
|
||||
fn property_group_name_from_derived_name(name: &str) -> String {
|
||||
format!("{}_fluid_properties", name).to_upper_camel_case()
|
||||
format!("{name}_fluid_properties").to_upper_camel_case()
|
||||
}
|
||||
|
||||
struct PropertyVariantMapping {
|
||||
@@ -55,7 +55,7 @@ impl ToTokens for PropertyStruct {
|
||||
|
||||
let ident_values = self.values.iter().map(|value| {
|
||||
let value_str = if value.chars().all(|c| c.is_numeric()) {
|
||||
format!("L{}", value)
|
||||
format!("L{value}")
|
||||
} else {
|
||||
value.clone()
|
||||
};
|
||||
@@ -67,7 +67,7 @@ impl ToTokens for PropertyStruct {
|
||||
|
||||
let from_values = self.values.iter().map(|value| {
|
||||
let value_str = if value.chars().all(|c| c.is_numeric()) {
|
||||
format!("L{}", value)
|
||||
format!("L{value}")
|
||||
} else {
|
||||
value.clone()
|
||||
};
|
||||
@@ -78,7 +78,7 @@ impl ToTokens for PropertyStruct {
|
||||
});
|
||||
let to_values = self.values.iter().map(|value| {
|
||||
let value_str = if value.chars().all(|c| c.is_numeric()) {
|
||||
format!("L{}", value)
|
||||
format!("L{value}")
|
||||
} else {
|
||||
value.clone()
|
||||
};
|
||||
@@ -345,7 +345,7 @@ pub(crate) fn build() -> TokenStream {
|
||||
|
||||
let fluids: Vec<Fluid> = match serde_json::from_str(include_str!("../../assets/fluids.json")) {
|
||||
Ok(fluids) => fluids,
|
||||
Err(e) => panic!("Failed to parse fluids.json: {}", e),
|
||||
Err(e) => panic!("Failed to parse fluids.json: {e}"),
|
||||
};
|
||||
|
||||
let mut constants = TokenStream::new();
|
||||
|
||||
@@ -384,7 +384,7 @@ impl Inventory for PlayerInventory {
|
||||
Some(slot) => {
|
||||
self.entity_equipment.lock().await.put(slot, stack).await;
|
||||
}
|
||||
None => log::warn!("Failed to get Equipment Slot at {0}", slot),
|
||||
None => log::warn!("Failed to get Equipment Slot at {slot}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -398,7 +398,7 @@ impl PlayerInventory {
|
||||
self.selected_slot
|
||||
.store(slot, std::sync::atomic::Ordering::Relaxed);
|
||||
} else {
|
||||
panic!("Invalid hotbar slot: {}", slot);
|
||||
panic!("Invalid hotbar slot: {slot}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -274,8 +274,7 @@ impl<'de, R: Read> de::Deserializer<'de> for &mut Deserializer<R> {
|
||||
}
|
||||
} else {
|
||||
Err(Error::UnsupportedType(format!(
|
||||
"Non-byte bool (found type {})",
|
||||
tag_id
|
||||
"Non-byte bool (found type {tag_id})"
|
||||
)))
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -203,7 +203,7 @@ mod tests {
|
||||
|
||||
// Add 1000 integer entries
|
||||
for i in 0..1000 {
|
||||
compound.put_int(&format!("value_{}", i), i);
|
||||
compound.put_int(&format!("value_{i}"), i);
|
||||
}
|
||||
|
||||
let mut buffer = Vec::new();
|
||||
@@ -281,7 +281,7 @@ mod tests {
|
||||
let mut buffer = Vec::new();
|
||||
write_gzip_compound_tag(&compound, &mut buffer).expect("Failed to compress compound");
|
||||
|
||||
println!("Uncompressed size (est): {} bytes", uncompressed);
|
||||
println!("Uncompressed size (est): {uncompressed} bytes");
|
||||
println!("Compressed size: {} bytes", buffer.len());
|
||||
println!(
|
||||
"Compression ratio: {:.2}x",
|
||||
|
||||
@@ -154,8 +154,7 @@ impl<W: Write> Serializer<W> {
|
||||
} else {
|
||||
if tag != COMPOUND_ID {
|
||||
return Err(Error::SerdeError(format!(
|
||||
"Invalid state: root is not a `Compound`! ({})",
|
||||
tag
|
||||
"Invalid state: root is not a `Compound`! ({tag})"
|
||||
)));
|
||||
}
|
||||
self.handled_root = true;
|
||||
|
||||
@@ -421,10 +421,7 @@ mod tests {
|
||||
|
||||
// Build the packet with compression enabled
|
||||
let packet = build_packet(packet_id, &payload, true, None, None);
|
||||
println!(
|
||||
"Built packet (with compression, maximum length): {:?}",
|
||||
packet
|
||||
);
|
||||
println!("Built packet (with compression, maximum length): {packet:?}");
|
||||
|
||||
// Initialize the decoder with compression enabled
|
||||
let mut decoder = NetworkDecoder::new(packet.as_slice());
|
||||
|
||||
@@ -146,8 +146,7 @@ impl<W: AsyncWrite + Unpin> NetworkEncoder<W> {
|
||||
}
|
||||
let data_len_var_int: VarInt = data_len.try_into().map_err(|_| {
|
||||
PacketEncodeError::Message(format!(
|
||||
"Packet data length is too large to fit in VarInt! ({})",
|
||||
data_len
|
||||
"Packet data length is too large to fit in VarInt! ({data_len})"
|
||||
))
|
||||
})?;
|
||||
|
||||
@@ -180,8 +179,7 @@ impl<W: AsyncWrite + Unpin> NetworkEncoder<W> {
|
||||
.try_into()
|
||||
.map_err(|_| {
|
||||
PacketEncodeError::Message(format!(
|
||||
"Full packet length is too large to fit in VarInt! ({})",
|
||||
data_len
|
||||
"Full packet length is too large to fit in VarInt! ({data_len})"
|
||||
))
|
||||
})?;
|
||||
|
||||
@@ -213,8 +211,7 @@ impl<W: AsyncWrite + Unpin> NetworkEncoder<W> {
|
||||
.try_into()
|
||||
.map_err(|_| {
|
||||
PacketEncodeError::Message(format!(
|
||||
"Full packet length is too large to fit in VarInt! ({})",
|
||||
data_len
|
||||
"Full packet length is too large to fit in VarInt! ({data_len})"
|
||||
))
|
||||
})?;
|
||||
|
||||
|
||||
@@ -98,8 +98,7 @@ impl<W: Write> ser::Serializer for NonPrefixedSeqSerializer<'_, W> {
|
||||
T: ?Sized + Serialize,
|
||||
{
|
||||
Err(WritingError::Serde(format!(
|
||||
"Expected a sequence but found a newtype struct {}!",
|
||||
name
|
||||
"Expected a sequence but found a newtype struct {name}!"
|
||||
)))
|
||||
}
|
||||
|
||||
@@ -114,8 +113,7 @@ impl<W: Write> ser::Serializer for NonPrefixedSeqSerializer<'_, W> {
|
||||
T: ?Sized + Serialize,
|
||||
{
|
||||
Err(WritingError::Serde(format!(
|
||||
"Expected a sequence but found a newtype variant {}!",
|
||||
name
|
||||
"Expected a sequence but found a newtype variant {name}!"
|
||||
)))
|
||||
}
|
||||
|
||||
@@ -141,8 +139,7 @@ impl<W: Write> ser::Serializer for NonPrefixedSeqSerializer<'_, W> {
|
||||
_len: usize,
|
||||
) -> Result<Self::SerializeStruct, Self::Error> {
|
||||
Err(WritingError::Serde(format!(
|
||||
"Expected a sequence but found a struct {}!",
|
||||
name
|
||||
"Expected a sequence but found a struct {name}!"
|
||||
)))
|
||||
}
|
||||
|
||||
@@ -154,8 +151,7 @@ impl<W: Write> ser::Serializer for NonPrefixedSeqSerializer<'_, W> {
|
||||
_len: usize,
|
||||
) -> Result<Self::SerializeStructVariant, Self::Error> {
|
||||
Err(WritingError::Serde(format!(
|
||||
"Expected a sequence but found a struct variant {}!",
|
||||
name
|
||||
"Expected a sequence but found a struct variant {name}!"
|
||||
)))
|
||||
}
|
||||
|
||||
@@ -171,8 +167,7 @@ impl<W: Write> ser::Serializer for NonPrefixedSeqSerializer<'_, W> {
|
||||
_len: usize,
|
||||
) -> Result<Self::SerializeTupleStruct, Self::Error> {
|
||||
Err(WritingError::Serde(format!(
|
||||
"Expected a sequence but found a tuple struct {}!",
|
||||
name
|
||||
"Expected a sequence but found a tuple struct {name}!"
|
||||
)))
|
||||
}
|
||||
|
||||
@@ -184,8 +179,7 @@ impl<W: Write> ser::Serializer for NonPrefixedSeqSerializer<'_, W> {
|
||||
_len: usize,
|
||||
) -> Result<Self::SerializeTupleVariant, Self::Error> {
|
||||
Err(WritingError::Serde(format!(
|
||||
"Expected a sequence but found a tuple variant {}!",
|
||||
name
|
||||
"Expected a sequence but found a tuple variant {name}!"
|
||||
)))
|
||||
}
|
||||
|
||||
@@ -197,8 +191,7 @@ impl<W: Write> ser::Serializer for NonPrefixedSeqSerializer<'_, W> {
|
||||
|
||||
fn serialize_unit_struct(self, name: &'static str) -> Result<Self::Ok, Self::Error> {
|
||||
Err(WritingError::Serde(format!(
|
||||
"Expected a sequence but found a unit struct {}!",
|
||||
name
|
||||
"Expected a sequence but found a unit struct {name}!"
|
||||
)))
|
||||
}
|
||||
|
||||
@@ -209,8 +202,7 @@ impl<W: Write> ser::Serializer for NonPrefixedSeqSerializer<'_, W> {
|
||||
_variant: &'static str,
|
||||
) -> Result<Self::Ok, Self::Error> {
|
||||
Err(WritingError::Serde(format!(
|
||||
"Expected a sequence but found a unit variant {}!",
|
||||
name
|
||||
"Expected a sequence but found a unit variant {name}!"
|
||||
)))
|
||||
}
|
||||
}
|
||||
@@ -282,7 +274,7 @@ impl<W: Write> ser::Serializer for &mut Serializer<W> {
|
||||
let mut nbt_serializer =
|
||||
pumpkin_nbt::serializer::Serializer::new(&mut self.write, None);
|
||||
value.serialize(&mut nbt_serializer).map_err(|err| {
|
||||
WritingError::Serde(format!("Failed to serialize TextComponent NBT: {}", err))
|
||||
WritingError::Serde(format!("Failed to serialize TextComponent NBT: {err}"))
|
||||
})
|
||||
} else if name == NO_PREFIX_MARKER {
|
||||
value.serialize(NonPrefixedSeqSerializer { wrapped: self })
|
||||
@@ -302,7 +294,7 @@ impl<W: Write> ser::Serializer for &mut Serializer<W> {
|
||||
{
|
||||
self.write
|
||||
.write_var_int(&variant_index.try_into().map_err(|_| {
|
||||
WritingError::Message(format!("{} isn't representable as a VarInt", variant_index))
|
||||
WritingError::Message(format!("{variant_index} isn't representable as a VarInt"))
|
||||
})?)?;
|
||||
value.serialize(self)
|
||||
}
|
||||
@@ -317,7 +309,7 @@ impl<W: Write> ser::Serializer for &mut Serializer<W> {
|
||||
};
|
||||
|
||||
self.write.write_var_int(&len.try_into().map_err(|_| {
|
||||
WritingError::Message(format!("{} isn't representable as a VarInt", len))
|
||||
WritingError::Message(format!("{len} isn't representable as a VarInt"))
|
||||
})?)?;
|
||||
|
||||
Ok(self)
|
||||
@@ -368,7 +360,7 @@ impl<W: Write> ser::Serializer for &mut Serializer<W> {
|
||||
// Serialize ENUM index as varint
|
||||
self.write
|
||||
.write_var_int(&variant_index.try_into().map_err(|_| {
|
||||
WritingError::Message(format!("{} isn't representable as a VarInt", variant_index))
|
||||
WritingError::Message(format!("{variant_index} isn't representable as a VarInt"))
|
||||
})?)?;
|
||||
Ok(self)
|
||||
}
|
||||
@@ -402,7 +394,7 @@ impl<W: Write> ser::Serializer for &mut Serializer<W> {
|
||||
// For ENUMs, only write enum index as varint
|
||||
self.write
|
||||
.write_var_int(&variant_index.try_into().map_err(|_| {
|
||||
WritingError::Message(format!("{} isn't representable as a VarInt", variant_index))
|
||||
WritingError::Message(format!("{variant_index} isn't representable as a VarInt"))
|
||||
})?)
|
||||
}
|
||||
fn is_human_readable(&self) -> bool {
|
||||
|
||||
@@ -228,7 +228,7 @@ impl OctavePerlinNoiseSampler {
|
||||
if amplitudes[k] != 0f64 {
|
||||
let l = first_octave + k as i32;
|
||||
samplers[k] = Some(PerlinNoiseSampler::new(
|
||||
&mut splitter.split_string(&format!("octave_{}", l)),
|
||||
&mut splitter.split_string(&format!("octave_{l}")),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,8 +52,7 @@ impl<'de> Deserialize<'de> for PermissionLvl {
|
||||
3 => Ok(PermissionLvl::Three),
|
||||
4 => Ok(PermissionLvl::Four),
|
||||
_ => Err(serde::de::Error::custom(format!(
|
||||
"Invalid value for OpLevel: {}",
|
||||
value
|
||||
"Invalid value for OpLevel: {value}"
|
||||
))),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ impl TagType {
|
||||
pub fn serialize(&self) -> String {
|
||||
match self {
|
||||
TagType::Item(name) => name.clone(),
|
||||
TagType::Tag(tag) => format!("#{}", tag),
|
||||
TagType::Tag(tag) => format!("#{tag}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ impl AnvilChunkFile {
|
||||
}
|
||||
|
||||
async fn write_indices(&self, path: &Path, indices: &[usize]) -> Result<(), std::io::Error> {
|
||||
log::trace!("Writing in place: {:?}", path);
|
||||
log::trace!("Writing in place: {path:?}");
|
||||
|
||||
let file = tokio::fs::OpenOptions::new()
|
||||
.read(false)
|
||||
@@ -454,7 +454,7 @@ impl AnvilChunkFile {
|
||||
/// Write entire file, disregarding saved offsets
|
||||
async fn write_all(&self, path: &Path) -> Result<(), std::io::Error> {
|
||||
let temp_path = path.with_extension("tmp");
|
||||
log::trace!("Writing tmp file to disk: {:?}", temp_path);
|
||||
log::trace!("Writing tmp file to disk: {temp_path:?}");
|
||||
|
||||
let file = tokio::fs::OpenOptions::new()
|
||||
.read(false)
|
||||
@@ -500,7 +500,7 @@ impl AnvilChunkFile {
|
||||
// that the data is not corrupted before the rename is completed
|
||||
tokio::fs::rename(temp_path, path).await?;
|
||||
|
||||
log::trace!("Wrote file to Disk: {:?}", path);
|
||||
log::trace!("Wrote file to Disk: {path:?}");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -527,17 +527,14 @@ impl ChunkSerializer for AnvilChunkFile {
|
||||
|
||||
fn get_chunk_key(chunk: &Vector2<i32>) -> String {
|
||||
let (region_x, region_z) = Self::get_region_coords(chunk);
|
||||
format!("./r.{}.{}.mca", region_x, region_z)
|
||||
format!("./r.{region_x}.{region_z}.mca")
|
||||
}
|
||||
|
||||
async fn write(&self, path: PathBuf) -> Result<(), std::io::Error> {
|
||||
let mut write_action = self.write_action.lock().await;
|
||||
match &*write_action {
|
||||
WriteAction::Pass => {
|
||||
log::debug!(
|
||||
"Skipping write for {:?} as there were no dirty chunks",
|
||||
path
|
||||
);
|
||||
log::debug!("Skipping write for {path:?} as there were no dirty chunks");
|
||||
Ok(())
|
||||
}
|
||||
WriteAction::All => self.write_all(&path).await,
|
||||
@@ -757,11 +754,7 @@ impl ChunkSerializer for AnvilChunkFile {
|
||||
let offset = new_sectors as i64 - swapped_sectors as i64;
|
||||
|
||||
log::trace!(
|
||||
"Swapping {} with {}, shifting all chunks {} and after by {}",
|
||||
index,
|
||||
swapped_index,
|
||||
swapped_index,
|
||||
offset
|
||||
"Swapping {index} with {swapped_index}, shifting all chunks {swapped_index} and after by {offset}"
|
||||
);
|
||||
|
||||
for shift_index in indices_to_shift {
|
||||
@@ -946,7 +939,7 @@ mod tests {
|
||||
LoadedData::Loaded(chunk) => chunk,
|
||||
LoadedData::Missing(_) => panic!("Missing chunk"),
|
||||
LoadedData::Error((position, error)) => {
|
||||
panic!("Error reading chunk at {:?} | Error: {:?}", position, error)
|
||||
panic!("Error reading chunk at {position:?} | Error: {error:?}")
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
@@ -1034,7 +1027,7 @@ mod tests {
|
||||
.enumerate()
|
||||
.for_each(|(i, (o, r))| {
|
||||
if o != r {
|
||||
panic!("Data miss-match expected {}, got {} ({})", o, r, i);
|
||||
panic!("Data miss-match expected {o}, got {r} ({i})");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1047,7 +1040,7 @@ mod tests {
|
||||
.enumerate()
|
||||
.for_each(|(i, (o, r))| {
|
||||
if o != r {
|
||||
panic!("Data miss-match expected {}, got {} ({})", o, r, i);
|
||||
panic!("Data miss-match expected {o}, got {r} ({i})");
|
||||
}
|
||||
});
|
||||
break;
|
||||
@@ -1092,7 +1085,7 @@ mod tests {
|
||||
.enumerate()
|
||||
.for_each(|(i, (o, r))| {
|
||||
if o != r {
|
||||
panic!("Data miss-match expected {}, got {} ({})", o, r, i);
|
||||
panic!("Data miss-match expected {o}, got {r} ({i})");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1105,7 +1098,7 @@ mod tests {
|
||||
.enumerate()
|
||||
.for_each(|(i, (o, r))| {
|
||||
if o != r {
|
||||
panic!("Data miss-match expected {}, got {} ({})", o, r, i);
|
||||
panic!("Data miss-match expected {o}, got {r} ({i})");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1165,7 +1158,7 @@ mod tests {
|
||||
.enumerate()
|
||||
.for_each(|(i, (o, r))| {
|
||||
if o != r {
|
||||
panic!("Data miss-match expected {}, got {} ({})", o, r, i);
|
||||
panic!("Data miss-match expected {o}, got {r} ({i})");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1178,7 +1171,7 @@ mod tests {
|
||||
.enumerate()
|
||||
.for_each(|(i, (o, r))| {
|
||||
if o != r {
|
||||
panic!("Data miss-match expected {}, got {} ({})", o, r, i);
|
||||
panic!("Data miss-match expected {o}, got {r} ({i})");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1226,7 +1219,7 @@ mod tests {
|
||||
.enumerate()
|
||||
.for_each(|(i, (o, r))| {
|
||||
if o != r {
|
||||
panic!("Data miss-match expected {}, got {} ({})", o, r, i);
|
||||
panic!("Data miss-match expected {o}, got {r} ({i})");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1239,7 +1232,7 @@ mod tests {
|
||||
.enumerate()
|
||||
.for_each(|(i, (o, r))| {
|
||||
if o != r {
|
||||
panic!("Data miss-match expected {}, got {} ({})", o, r, i);
|
||||
panic!("Data miss-match expected {o}, got {r} ({i})");
|
||||
}
|
||||
});
|
||||
break;
|
||||
@@ -1307,7 +1300,7 @@ mod tests {
|
||||
.enumerate()
|
||||
.for_each(|(i, (o, r))| {
|
||||
if o != r {
|
||||
panic!("Data miss-match expected {}, got {} ({})", o, r, i);
|
||||
panic!("Data miss-match expected {o}, got {r} ({i})");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1320,7 +1313,7 @@ mod tests {
|
||||
.enumerate()
|
||||
.for_each(|(i, (o, r))| {
|
||||
if o != r {
|
||||
panic!("Data miss-match expected {}, got {} ({})", o, r, i);
|
||||
panic!("Data miss-match expected {o}, got {r} ({i})");
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
@@ -169,7 +169,7 @@ impl ChunkSerializer for LinearFile {
|
||||
|
||||
fn get_chunk_key(chunk: &Vector2<i32>) -> String {
|
||||
let (region_x, region_z) = AnvilChunkFile::get_region_coords(chunk);
|
||||
format!("./r.{}.{}.linear", region_x, region_z)
|
||||
format!("./r.{region_x}.{region_z}.linear")
|
||||
}
|
||||
|
||||
async fn write(&self, path: PathBuf) -> Result<(), std::io::Error> {
|
||||
|
||||
@@ -277,7 +277,7 @@ where
|
||||
.into_iter()
|
||||
.map(async |(file_name, chunk_locks)| {
|
||||
let path = Self::map_key(folder, &file_name);
|
||||
log::trace!("Updating data for file {:?}", path);
|
||||
log::trace!("Updating data for file {path:?}");
|
||||
|
||||
let chunk_serializer = match self.get_serializer(&path).await {
|
||||
Ok(file) => Ok(file),
|
||||
@@ -285,11 +285,11 @@ where
|
||||
unreachable!("Must be managed by the cache")
|
||||
}
|
||||
Err(ChunkReadingError::IoError(err)) => {
|
||||
error!("Error reading the data before write: {}", err);
|
||||
error!("Error reading the data before write: {err}");
|
||||
Err(ChunkWritingError::IoError(err))
|
||||
}
|
||||
Err(err) => {
|
||||
error!("Error reading the data before write: {:?}", err);
|
||||
error!("Error reading the data before write: {err:?}");
|
||||
Err(ChunkWritingError::IoError(std::io::ErrorKind::Other))
|
||||
}
|
||||
}?;
|
||||
@@ -310,7 +310,7 @@ where
|
||||
serializer.update_chunk(&*chunk).await?;
|
||||
}
|
||||
}
|
||||
log::trace!("Updated data for file {:?}", path);
|
||||
log::trace!("Updated data for file {path:?}");
|
||||
|
||||
let is_watched = self
|
||||
.watchers
|
||||
@@ -324,7 +324,7 @@ where
|
||||
// to avoid other threads to write/modify the data, but allow other threads to read it
|
||||
let serializer = serializer.downgrade();
|
||||
|
||||
log::debug!("Writing file for {:?}", path);
|
||||
log::debug!("Writing file for {path:?}");
|
||||
serializer
|
||||
.write(path.clone())
|
||||
.await
|
||||
@@ -353,9 +353,9 @@ where
|
||||
|
||||
if can_remove {
|
||||
locks.remove(&path);
|
||||
log::trace!("Removed lockfile cache {:?}", path);
|
||||
log::trace!("Removed lockfile cache {path:?}");
|
||||
} else {
|
||||
log::trace!("Wanted to remove lockfile cache {:?} but someone still holds a reference to it!", path);
|
||||
log::trace!("Wanted to remove lockfile cache {path:?} but someone still holds a reference to it!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ impl From<i32> for TickPriority {
|
||||
1 => TickPriority::Low,
|
||||
2 => TickPriority::VeryLow,
|
||||
3 => TickPriority::ExtremelyLow,
|
||||
_ => panic!("Invalid tick priority: {}", value),
|
||||
_ => panic!("Invalid tick priority: {value}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,11 +30,7 @@ impl PlayerDataStorage {
|
||||
let path = data_path.into();
|
||||
if !path.exists() {
|
||||
if let Err(e) = create_dir_all(&path) {
|
||||
log::error!(
|
||||
"Failed to create player data directory at {:?}: {}",
|
||||
path,
|
||||
e
|
||||
);
|
||||
log::error!("Failed to create player data directory at {path:?}: {e}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,25 +80,25 @@ impl PlayerDataStorage {
|
||||
// If not in cache, load from disk
|
||||
let path = self.get_player_data_path(uuid);
|
||||
if !path.exists() {
|
||||
log::debug!("No player data file found for {}", uuid);
|
||||
log::debug!("No player data file found for {uuid}");
|
||||
return Ok((false, NbtCompound::new()));
|
||||
}
|
||||
|
||||
let file = match File::open(&path) {
|
||||
Ok(file) => file,
|
||||
Err(e) => {
|
||||
log::error!("Failed to open player data file for {}: {}", uuid, e);
|
||||
log::error!("Failed to open player data file for {uuid}: {e}");
|
||||
return Err(PlayerDataError::Io(e));
|
||||
}
|
||||
};
|
||||
|
||||
match pumpkin_nbt::nbt_compress::read_gzip_compound_tag(file) {
|
||||
Ok(nbt) => {
|
||||
log::debug!("Loaded player data for {} from disk", uuid);
|
||||
log::debug!("Loaded player data for {uuid} from disk");
|
||||
Ok((true, nbt))
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Failed to read player data for {}: {}", uuid, e);
|
||||
log::error!("Failed to read player data for {uuid}: {e}");
|
||||
Err(PlayerDataError::Nbt(e.to_string()))
|
||||
}
|
||||
}
|
||||
@@ -132,7 +128,7 @@ impl PlayerDataStorage {
|
||||
// Ensure parent directory exists
|
||||
if let Some(parent) = path.parent() {
|
||||
if let Err(e) = create_dir_all(parent) {
|
||||
log::error!("Failed to create player data directory for {}: {}", uuid, e);
|
||||
log::error!("Failed to create player data directory for {uuid}: {e}");
|
||||
return Err(PlayerDataError::Io(e));
|
||||
}
|
||||
}
|
||||
@@ -141,15 +137,15 @@ impl PlayerDataStorage {
|
||||
match File::create(&path) {
|
||||
Ok(file) => {
|
||||
if let Err(e) = pumpkin_nbt::nbt_compress::write_gzip_compound_tag(&data, file) {
|
||||
log::error!("Failed to write compressed player data for {}: {}", uuid, e);
|
||||
log::error!("Failed to write compressed player data for {uuid}: {e}");
|
||||
Err(PlayerDataError::Nbt(e.to_string()))
|
||||
} else {
|
||||
log::debug!("Saved player data for {} to disk", uuid);
|
||||
log::debug!("Saved player data for {uuid} to disk");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Failed to create player data file for {}: {}", uuid, e);
|
||||
log::error!("Failed to create player data file for {uuid}: {e}");
|
||||
Err(PlayerDataError::Io(e))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,8 +194,7 @@ mod test {
|
||||
let expected = Vector3::new(result_x, result_y, result_z);
|
||||
assert_eq!(
|
||||
result, expected,
|
||||
"Expected: {:?}, was: {:?} ({})",
|
||||
expected, result, i
|
||||
"Expected: {expected:?}, was: {result:?} ({i})"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ impl<'a> DoublePerlinNoiseBuilder<'a> {
|
||||
|
||||
pub fn get_noise_sampler_for_id(&mut self, id: &str) -> DoublePerlinNoiseSampler {
|
||||
let parameters = DoublePerlinNoiseParameters::id_to_parameters(id)
|
||||
.unwrap_or_else(|| panic!("Unknown noise id: {}", id));
|
||||
.unwrap_or_else(|| panic!("Unknown noise id: {id}"));
|
||||
|
||||
// Note that the parameters' id is different than `id`
|
||||
let mut random = self
|
||||
|
||||
@@ -100,11 +100,11 @@ impl Level {
|
||||
WorldInfoError::InfoNotFound => (),
|
||||
WorldInfoError::UnsupportedVersion(version) => {
|
||||
log::error!("Failed to load world info!, {version}");
|
||||
log::error!("{}", error);
|
||||
log::error!("{error}");
|
||||
panic!("Unsupported world data! See the logs for more info.");
|
||||
}
|
||||
e => {
|
||||
panic!("World Error {}", e);
|
||||
panic!("World Error {e}");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -189,7 +189,7 @@ impl Level {
|
||||
|
||||
// Lets not stop the overall save for this
|
||||
if let Err(err) = result {
|
||||
log::error!("Failed to save level.dat: {}", err);
|
||||
log::error!("Failed to save level.dat: {err}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ impl Level {
|
||||
/// before
|
||||
pub async fn mark_chunks_as_newly_watched(&self, chunks: &[Vector2<i32>]) {
|
||||
for chunk in chunks {
|
||||
log::trace!("{:?} marked as newly watched", chunk);
|
||||
log::trace!("{chunk:?} marked as newly watched");
|
||||
match self.chunk_watchers.entry(*chunk) {
|
||||
Entry::Occupied(mut occupied) => {
|
||||
let value = occupied.get_mut();
|
||||
@@ -220,7 +220,7 @@ impl Level {
|
||||
*value = new_value;
|
||||
//log::debug!("Watch value for {:?}: {}", chunk, value);
|
||||
} else {
|
||||
log::error!("Watching overflow on chunk {:?}", chunk);
|
||||
log::error!("Watching overflow on chunk {chunk:?}");
|
||||
}
|
||||
}
|
||||
Entry::Vacant(vacant) => {
|
||||
@@ -245,7 +245,7 @@ impl Level {
|
||||
let mut chunks_to_clean = Vec::new();
|
||||
|
||||
for chunk in chunks {
|
||||
log::trace!("{:?} marked as no longer watched", chunk);
|
||||
log::trace!("{chunk:?} marked as no longer watched");
|
||||
match self.chunk_watchers.entry(*chunk) {
|
||||
Entry::Occupied(mut occupied) => {
|
||||
let value = occupied.get_mut();
|
||||
@@ -391,7 +391,7 @@ impl Level {
|
||||
.save_chunks(&level_folder, chunks_to_write)
|
||||
.await
|
||||
{
|
||||
log::error!("Failed writing Chunk to disk {}", error);
|
||||
log::error!("Failed writing Chunk to disk {error}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,9 +501,7 @@ impl Level {
|
||||
// this is an error, and we should log it
|
||||
error => {
|
||||
log::error!(
|
||||
"Failed to load chunk at {:?}: {} (regenerating)",
|
||||
pos,
|
||||
error
|
||||
"Failed to load chunk at {pos:?}: {error} (regenerating)"
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,5 +15,5 @@ fn main() {
|
||||
"unknown" => env::var("GIT_VERSION").unwrap_or("unknown".to_string()),
|
||||
_ => version.to_string(),
|
||||
};
|
||||
println!("cargo:rustc-env=GIT_VERSION={}", git_version);
|
||||
println!("cargo:rustc-env=GIT_VERSION={git_version}");
|
||||
}
|
||||
|
||||
@@ -142,8 +142,7 @@ pub static LOGGER_IMPL: LazyLock<Option<(ReadlineLogWrapper, LevelFilter)>> = La
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!(
|
||||
"Failed to initialize console input ({}); falling back to simple logger",
|
||||
e
|
||||
"Failed to initialize console input ({e}); falling back to simple logger"
|
||||
);
|
||||
let logger = simplelog::SimpleLogger::new(level, config.build());
|
||||
Some((ReadlineLogWrapper::new(logger, None), level))
|
||||
@@ -261,7 +260,7 @@ impl PumpkinServer {
|
||||
let mut loader_lock = PLUGIN_MANAGER.lock().await;
|
||||
loader_lock.set_server(self.server.clone());
|
||||
if let Err(err) = loader_lock.load_plugins().await {
|
||||
log::error!("{}", err);
|
||||
log::error!("{err}");
|
||||
};
|
||||
}
|
||||
|
||||
@@ -297,11 +296,7 @@ impl PumpkinServer {
|
||||
} else {
|
||||
format!("{client_addr}")
|
||||
};
|
||||
log::debug!(
|
||||
"Accepted connection from: {} (id {})",
|
||||
formatted_address,
|
||||
id
|
||||
);
|
||||
log::debug!("Accepted connection from: {formatted_address} (id {id})");
|
||||
|
||||
let mut client = Client::new(connection, client_addr, id);
|
||||
client.init();
|
||||
@@ -325,7 +320,7 @@ impl PumpkinServer {
|
||||
player.close().await;
|
||||
|
||||
//TODO: Move these somewhere less likely to be forgotten
|
||||
log::debug!("Cleaning up player for id {}", id);
|
||||
log::debug!("Cleaning up player for id {id}");
|
||||
|
||||
// Save player data on disconnect
|
||||
if let Err(e) = server
|
||||
@@ -333,7 +328,7 @@ impl PumpkinServer {
|
||||
.handle_player_leave(&player)
|
||||
.await
|
||||
{
|
||||
log::error!("Failed to save player data on disconnect: {}", e);
|
||||
log::error!("Failed to save player data on disconnect: {e}");
|
||||
}
|
||||
|
||||
// Remove the player from its world
|
||||
@@ -345,9 +340,9 @@ impl PumpkinServer {
|
||||
// Also handle case of client connects but does not become a player (like a server
|
||||
// ping)
|
||||
client.close();
|
||||
log::debug!("Awaiting tasks for client {}", id);
|
||||
log::debug!("Awaiting tasks for client {id}");
|
||||
client.await_tasks().await;
|
||||
log::debug!("Finished awaiting tasks for client {}", id);
|
||||
log::debug!("Finished awaiting tasks for client {id}");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -360,7 +355,7 @@ impl PumpkinServer {
|
||||
.save_all_players(&self.server)
|
||||
.await
|
||||
{
|
||||
log::error!("Error saving all players during shutdown: {}", e);
|
||||
log::error!("Error saving all players during shutdown: {e}");
|
||||
}
|
||||
|
||||
let kick_message = TextComponent::text("Server stopped");
|
||||
@@ -463,7 +458,7 @@ fn setup_console(rl: Readline, server: Arc<Server>) {
|
||||
}
|
||||
err => {
|
||||
log::error!("Console command loop failed!");
|
||||
log::error!("{:?}", err);
|
||||
log::error!("{err:?}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user