mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 06:16:04 +00:00
fix panic in azalea-chat
This commit is contained in:
parent
5a0045c985
commit
0b3ec4ee3b
1 changed files with 8 additions and 1 deletions
|
@ -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()));
|
||||
|
|
Loading…
Add table
Reference in a new issue