diff options
| author | mat <github@matdoes.dev> | 2022-09-11 09:47:54 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-09-11 09:47:54 -0500 |
| commit | 0b3ec4ee3b53fedf51470e54ceeceff0e0cfdb69 (patch) | |
| tree | a2a6dad7e516ddbc9695a3cf7829fe5c38ba745c | |
| parent | 5a0045c9851fb008c97562eccc14fa42cf3ae498 (diff) | |
| download | azalea-drasl-0b3ec4ee3b53fedf51470e54ceeceff0e0cfdb69.tar.xz | |
fix panic in azalea-chat
| -rwxr-xr-x | azalea-chat/src/text_component.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/azalea-chat/src/text_component.rs b/azalea-chat/src/text_component.rs index 564511fc..a061924f 100755 --- a/azalea-chat/src/text_component.rs +++ b/azalea-chat/src/text_component.rs @@ -21,7 +21,14 @@ pub fn legacy_color_code_to_text_component(legacy_color_code: &str) -> TextCompo let mut i = 0; while i < legacy_color_code.chars().count() { if legacy_color_code.chars().nth(i).unwrap() == LEGACY_FORMATTING_CODE_SYMBOL { - let formatting_code = legacy_color_code.chars().nth(i + 1).unwrap(); + let formatting_code = legacy_color_code.chars().nth(i + 1); + let formatting_code = match formatting_code { + Some(formatting_code) => formatting_code, + None => { + i += 1; + continue; + } + }; if let Some(formatter) = ChatFormatting::from_code(formatting_code) { if components.is_empty() || !components.last().unwrap().text.is_empty() { components.push(TextComponent::new("".to_string())); |
