1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 14:26:04 +00:00

don't panic if TranslatableComponent::to_string fails

This commit is contained in:
mat 2023-08-20 23:52:01 -05:00
parent e511ad3c31
commit 1b6e024460

View file

@ -133,7 +133,10 @@ impl Display for TranslatableComponent {
for component in FormattedText::Translatable(self.clone()).into_iter() { for component in FormattedText::Translatable(self.clone()).into_iter() {
let component_text = match &component { let component_text = match &component {
FormattedText::Text(c) => c.text.to_string(), FormattedText::Text(c) => c.text.to_string(),
FormattedText::Translatable(c) => c.read()?.to_string(), FormattedText::Translatable(c) => match c.read() {
Ok(c) => c.to_string(),
Err(_) => c.key.to_string(),
},
}; };
f.write_str(&component_text)?; f.write_str(&component_text)?;