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