diff options
| author | mat <git@matdoes.dev> | 2026-05-06 18:38:23 -0545 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2026-05-07 08:05:58 -1200 |
| commit | cabc8b60a729ba17f5b75f7a7956c6d1ddcc8919 (patch) | |
| tree | 237fd12a9768fe7431ce42dfbdde60f4c7850e06 /azalea-brigadier/src/context/command_context_builder.rs | |
| parent | 9ffd0e80bbb3feace231553d6539124585b03e3c (diff) | |
| download | azalea-drasl-cabc8b60a729ba17f5b75f7a7956c6d1ddcc8919.tar.xz | |
azalea-brigadier now allows commands to return a Result
Diffstat (limited to 'azalea-brigadier/src/context/command_context_builder.rs')
| -rw-r--r-- | azalea-brigadier/src/context/command_context_builder.rs | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/azalea-brigadier/src/context/command_context_builder.rs b/azalea-brigadier/src/context/command_context_builder.rs index a3819246..e3b09fc1 100644 --- a/azalea-brigadier/src/context/command_context_builder.rs +++ b/azalea-brigadier/src/context/command_context_builder.rs @@ -17,20 +17,20 @@ use crate::{ tree::{Command, CommandNode}, }; -pub struct CommandContextBuilder<'a, S> { +pub struct CommandContextBuilder<'a, S, R> { pub arguments: HashMap<String, ParsedArgument>, - pub root: Arc<RwLock<CommandNode<S>>>, - pub nodes: Vec<ParsedCommandNode<S>>, - pub dispatcher: &'a CommandDispatcher<S>, + pub root: Arc<RwLock<CommandNode<S, R>>>, + pub nodes: Vec<ParsedCommandNode<S, R>>, + pub dispatcher: &'a CommandDispatcher<S, R>, pub source: Arc<S>, - pub command: Command<S>, - pub child: Option<Rc<CommandContextBuilder<'a, S>>>, + pub command: Command<S, R>, + pub child: Option<Rc<CommandContextBuilder<'a, S, R>>>, pub range: StringRange, - pub modifier: Option<Arc<RedirectModifier<S>>>, + pub modifier: Option<Arc<RedirectModifier<S, R>>>, pub forks: bool, } -impl<S> Clone for CommandContextBuilder<'_, S> { +impl<S, R> Clone for CommandContextBuilder<'_, S, R> { fn clone(&self) -> Self { Self { arguments: self.arguments.clone(), @@ -47,11 +47,11 @@ impl<S> Clone for CommandContextBuilder<'_, S> { } } -impl<'a, S> CommandContextBuilder<'a, S> { +impl<'a, S, R> CommandContextBuilder<'a, S, R> { pub fn new( - dispatcher: &'a CommandDispatcher<S>, + dispatcher: &'a CommandDispatcher<S, R>, source: Arc<S>, - root_node: Arc<RwLock<CommandNode<S>>>, + root_node: Arc<RwLock<CommandNode<S, R>>>, start: usize, ) -> Self { Self { @@ -68,11 +68,11 @@ impl<'a, S> CommandContextBuilder<'a, S> { } } - pub fn with_command(&mut self, command: &Command<S>) -> &Self { + pub fn with_command(&mut self, command: &Command<S, R>) -> &Self { self.command.clone_from(command); self } - pub fn with_child(&mut self, child: Rc<CommandContextBuilder<'a, S>>) -> &Self { + pub fn with_child(&mut self, child: Rc<CommandContextBuilder<'a, S, R>>) -> &Self { self.child = Some(child); self } @@ -80,7 +80,7 @@ impl<'a, S> CommandContextBuilder<'a, S> { self.arguments.insert(name.to_owned(), argument); self } - pub fn with_node(&mut self, node: Arc<RwLock<CommandNode<S>>>, range: StringRange) -> &Self { + pub fn with_node(&mut self, node: Arc<RwLock<CommandNode<S, R>>>, range: StringRange) -> &Self { self.nodes.push(ParsedCommandNode { node: node.clone(), range, @@ -91,7 +91,7 @@ impl<'a, S> CommandContextBuilder<'a, S> { self } - pub fn build(&self, input: &str) -> CommandContext<S> { + pub fn build(&self, input: &str) -> CommandContext<S, R> { CommandContext { arguments: self.arguments.clone(), root_node: self.root.clone(), @@ -106,7 +106,7 @@ impl<'a, S> CommandContextBuilder<'a, S> { } } - pub fn find_suggestion_context(&self, cursor: usize) -> SuggestionContext<S> { + pub fn find_suggestion_context(&self, cursor: usize) -> SuggestionContext<S, R> { if self.range.start() > cursor { panic!("Can't find node before cursor"); } @@ -144,7 +144,7 @@ impl<'a, S> CommandContextBuilder<'a, S> { } } -impl<S> Debug for CommandContextBuilder<'_, S> { +impl<S, R> Debug for CommandContextBuilder<'_, S, R> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("CommandContextBuilder") // .field("arguments", &self.arguments) |
