diff options
| author | mat <github@matdoes.dev> | 2022-12-08 18:39:35 -0600 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-12-08 18:39:35 -0600 |
| commit | 70e2dfed16da8d5130460ea15b47701e622f4a9f (patch) | |
| tree | 41f670baf3a05ed180880ec2a11d8e5f6a1a1599 /azalea-chat/src/text_component.rs | |
| parent | f2076daba5cfcce81399b075ba9258fbdc2012fa (diff) | |
| download | azalea-drasl-70e2dfed16da8d5130460ea15b47701e622f4a9f.tar.xz | |
wrap_comments = true
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()); |
