diff options
| author | Ubuntu <github@matdoes.dev> | 2022-12-09 15:13:14 +0000 |
|---|---|---|
| committer | Ubuntu <github@matdoes.dev> | 2022-12-09 15:13:14 +0000 |
| commit | ca00dbab12ab7de0bba462b9814b9f491b23da69 (patch) | |
| tree | 560bd906d9ca1fcb822290286e9bf5990826163a /azalea-chat/src/text_component.rs | |
| parent | f0097612473d20ebac21e8ae5eba32bf32c2fe42 (diff) | |
| parent | 70e2dfed16da8d5130460ea15b47701e622f4a9f (diff) | |
| download | azalea-drasl-ca00dbab12ab7de0bba462b9814b9f491b23da69.tar.xz | |
Merge branch 'main' of https://github.com/mat-1/azalea into main
Diffstat (limited to 'azalea-chat/src/text_component.rs')
| -rwxr-xr-x | azalea-chat/src/text_component.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/azalea-chat/src/text_component.rs b/azalea-chat/src/text_component.rs index e5cc054e..44bcbcf1 100755 --- a/azalea-chat/src/text_component.rs +++ b/azalea-chat/src/text_component.rs @@ -27,13 +27,16 @@ impl Serialize for TextComponent { const LEGACY_FORMATTING_CODE_SYMBOL: char = 'ยง'; /// Convert a legacy color code string into a Component -/// Technically in Minecraft this is done when displaying the text, but AFAIK it's the same as just doing it in TextComponent +/// Technically in Minecraft this is done when displaying the text, but AFAIK +/// it's the same as just doing it in TextComponent pub fn legacy_color_code_to_text_component(legacy_color_code: &str) -> TextComponent { let mut components: Vec<TextComponent> = Vec::with_capacity(1); - // iterate over legacy_color_code, if it starts with LEGACY_COLOR_CODE_SYMBOL then read the next character and get the style from that - // otherwise, add the character to the text + // iterate over legacy_color_code, if it starts with LEGACY_COLOR_CODE_SYMBOL + // then read the next character and get the style from that otherwise, add + // the character to the text - // we don't use a normal for loop since we need to be able to skip after reading the formatter code symbol + // we don't use a normal for loop since we need to be able to skip after reading + // the formatter code symbol let mut i = 0; while i < legacy_color_code.chars().count() { if legacy_color_code.chars().nth(i).unwrap() == LEGACY_FORMATTING_CODE_SYMBOL { @@ -72,7 +75,8 @@ pub fn legacy_color_code_to_text_component(legacy_color_code: &str) -> TextCompo return TextComponent::new("".to_string()); } - // create the final component by using the first one as the base, and then adding the rest as siblings + // create the final component by using the first one as the base, and then + // adding the rest as siblings let mut final_component = components.remove(0); for component in components { final_component.base.siblings.push(component.get()); |
