aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-09-11 09:47:54 -0500
committermat <github@matdoes.dev>2022-09-11 09:47:54 -0500
commit0b3ec4ee3b53fedf51470e54ceeceff0e0cfdb69 (patch)
treea2a6dad7e516ddbc9695a3cf7829fe5c38ba745c
parent5a0045c9851fb008c97562eccc14fa42cf3ae498 (diff)
downloadazalea-drasl-0b3ec4ee3b53fedf51470e54ceeceff0e0cfdb69.tar.xz
fix panic in azalea-chat
-rwxr-xr-xazalea-chat/src/text_component.rs9
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()));