diff options
| author | mat <git@matdoes.dev> | 2025-05-30 20:07:28 -0330 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-05-30 16:37:40 -0700 |
| commit | a5e7ff771d657258cedcc7a8b3ce265c655f0860 (patch) | |
| tree | ea5fdbbee32c1b9917a7ece03f6a1a70ee8e63fa /azalea-brigadier/src/builder/argument_builder.rs | |
| parent | da73b4316de4b26322c53f14222c7751a0be55a1 (diff) | |
| download | azalea-drasl-a5e7ff771d657258cedcc7a8b3ce265c655f0860.tar.xz | |
implement missing brigadier features and cleanup some more
Diffstat (limited to 'azalea-brigadier/src/builder/argument_builder.rs')
| -rw-r--r-- | azalea-brigadier/src/builder/argument_builder.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/azalea-brigadier/src/builder/argument_builder.rs b/azalea-brigadier/src/builder/argument_builder.rs index bc7f0ac6..1731d44d 100644 --- a/azalea-brigadier/src/builder/argument_builder.rs +++ b/azalea-brigadier/src/builder/argument_builder.rs @@ -5,6 +5,7 @@ use parking_lot::RwLock; use super::{literal_argument_builder::Literal, required_argument_builder::Argument}; use crate::{ context::CommandContext, + errors::CommandSyntaxError, modifier::RedirectModifier, tree::{Command, CommandNode}, }; @@ -90,6 +91,16 @@ impl<S> ArgumentBuilder<S> { where F: Fn(&CommandContext<S>) -> i32 + Send + Sync + 'static, { + self.command = Some(Arc::new(move |ctx: &CommandContext<S>| Ok(f(ctx)))); + self + } + + /// Same as [`Self::executes`] but returns a `Result<i32, + /// CommandSyntaxError>`. + pub fn executes_result<F>(mut self, f: F) -> Self + where + F: Fn(&CommandContext<S>) -> Result<i32, CommandSyntaxError> + Send + Sync + 'static, + { self.command = Some(Arc::new(f)); self } |
