1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use valence_text::Color;

use super::Parser;
use crate::parsers::{CommandArg, CommandArgParseError, ParseInput};

impl CommandArg for Color {
    fn parse_arg(input: &mut ParseInput) -> Result<Self, CommandArgParseError> {
        input.skip_whitespace();
        if input.match_next("black") {
            Ok(Self::BLACK)
        } else if input.match_next("dark_blue") {
            Ok(Self::DARK_BLUE)
        } else if input.match_next("dark_green") {
            Ok(Self::DARK_GREEN)
        } else if input.match_next("dark_aqua") {
            Ok(Self::DARK_AQUA)
        } else if input.match_next("dark_red") {
            Ok(Self::DARK_RED)
        } else if input.match_next("dark_purple") {
            Ok(Self::DARK_PURPLE)
        } else if input.match_next("gold") {
            Ok(Self::GOLD)
        } else if input.match_next("gray") {
            Ok(Self::GRAY)
        } else if input.match_next("dark_gray") {
            Ok(Self::DARK_GRAY)
        } else if input.match_next("blue") {
            Ok(Self::BLUE)
        } else if input.match_next("green") {
            Ok(Self::GREEN)
        } else if input.match_next("aqua") {
            Ok(Self::AQUA)
        } else if input.match_next("red") {
            Ok(Self::RED)
        } else if input.match_next("light_purple") {
            Ok(Self::LIGHT_PURPLE)
        } else if input.match_next("yellow") {
            Ok(Self::YELLOW)
        } else if input.match_next("white") {
            Ok(Self::WHITE)
        } else if input.match_next("reset") {
            Ok(Self::Reset)
        } else {
            Err(CommandArgParseError::InvalidArgument {
                expected: "chat_color".to_owned(),
                got: "not a valid chat color".to_owned(),
            })
        }
    }

    fn display() -> Parser {
        Parser::Color
    }
}