From cabc8b60a729ba17f5b75f7a7956c6d1ddcc8919 Mon Sep 17 00:00:00 2001 From: mat Date: Wed, 6 May 2026 18:38:23 -0545 Subject: azalea-brigadier now allows commands to return a Result --- azalea-brigadier/src/context/command_context.rs | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'azalea-brigadier/src/context/command_context.rs') diff --git a/azalea-brigadier/src/context/command_context.rs b/azalea-brigadier/src/context/command_context.rs index a9959895..0139f7e9 100644 --- a/azalea-brigadier/src/context/command_context.rs +++ b/azalea-brigadier/src/context/command_context.rs @@ -15,20 +15,20 @@ use crate::{ }; /// A built `CommandContextBuilder`. -pub struct CommandContext { +pub struct CommandContext { pub source: Arc, pub(super) input: String, pub(super) arguments: HashMap, - pub(super) command: Command, - pub(super) root_node: Arc>>, - pub(super) nodes: Vec>, + pub(super) command: Command, + pub(super) root_node: Arc>>, + pub(super) nodes: Vec>, pub(super) range: StringRange, - pub(super) child: Option>>, - pub(super) modifier: Option>>, + pub(super) child: Option>>, + pub(super) modifier: Option>>, pub(super) forks: bool, } -impl Clone for CommandContext { +impl Clone for CommandContext { fn clone(&self) -> Self { Self { source: self.source.clone(), @@ -45,7 +45,7 @@ impl Clone for CommandContext { } } -impl Debug for CommandContext { +impl Debug for CommandContext { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("CommandContext") // .field("source", &self.source) @@ -62,7 +62,7 @@ impl Debug for CommandContext { } } -impl CommandContext { +impl CommandContext { pub fn copy_for(&self, source: Arc) -> Self { if Arc::ptr_eq(&source, &self.source) { // fast path @@ -83,11 +83,11 @@ impl CommandContext { } } - pub fn child(&self) -> Option<&CommandContext> { + pub fn child(&self) -> Option<&CommandContext> { self.child.as_ref().map(|c| c.as_ref()) } - pub fn last_child(&self) -> &CommandContext { + pub fn last_child(&self) -> &CommandContext { let mut result = self; while let Some(child) = result.child() { result = child; @@ -95,7 +95,7 @@ impl CommandContext { result } - pub fn command(&self) -> &Command { + pub fn command(&self) -> &Command { &self.command } @@ -104,7 +104,7 @@ impl CommandContext { argument.map(|a| a.result.as_ref()) } - pub fn redirect_modifier(&self) -> Option<&RedirectModifier> { + pub fn redirect_modifier(&self) -> Option<&RedirectModifier> { self.modifier.as_ref().map(|m| m.as_ref()) } @@ -116,11 +116,11 @@ impl CommandContext { &self.input } - pub fn root_node(&self) -> &Arc>> { + pub fn root_node(&self) -> &Arc>> { &self.root_node } - pub fn nodes(&self) -> &[ParsedCommandNode] { + pub fn nodes(&self) -> &[ParsedCommandNode] { &self.nodes } -- cgit v1.2.3