MCPcopy Create free account
hub / github.com/Vulae/pkmc / try_parse

Method try_parse

examples/server/src/player/command.rs:88–105  ·  view source on GitHub ↗
(
        parser: &mut CommandParser<'_>,
        arg: &Self::ParseArg,
    )

Source from the content-addressed store, hash-verified

86
87 type ParseArg = CommandCoordinateTransform;
88 fn try_parse(
89 parser: &mut CommandParser<'_>,
90 arg: &Self::ParseArg,
91 ) -> Result<Option<Self>, CommandParseError> {
92 if parser.consume_literal("goto").is_err() {
93 return Ok(None);
94 }
95 Ok(Some(Self {
96 position: parser
97 .consume::<CommandParsableCoordinate>()?
98 .to_coordinates(arg),
99 dimension: if parser.consume_until_space_or_end(false)? == "in" {
100 Some(parser.consume_until_space_or_end(true)?.to_owned())
101 } else {
102 None
103 },
104 }))
105 }
106}
107
108impl PlayerExecutableCommand for CommandGoto {

Callers

nothing calls this directly

Calls 5

consume_literalMethod · 0.80
to_coordinatesMethod · 0.80
to_positionMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected