From a5e7ff771d657258cedcc7a8b3ce265c655f0860 Mon Sep 17 00:00:00 2001 From: mat Date: Fri, 30 May 2025 20:07:28 -0330 Subject: implement missing brigadier features and cleanup some more --- azalea-brigadier/src/builder/argument_builder.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'azalea-brigadier/src/builder/argument_builder.rs') 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}, }; @@ -89,6 +90,16 @@ impl ArgumentBuilder { pub fn executes(mut self, f: F) -> Self where F: Fn(&CommandContext) -> i32 + Send + Sync + 'static, + { + self.command = Some(Arc::new(move |ctx: &CommandContext| Ok(f(ctx)))); + self + } + + /// Same as [`Self::executes`] but returns a `Result`. + pub fn executes_result(mut self, f: F) -> Self + where + F: Fn(&CommandContext) -> Result + Send + Sync + 'static, { self.command = Some(Arc::new(f)); self -- cgit v1.2.3