From eb111be1f107696939b994f5de6e060cf972a732 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Thu, 13 Jan 2022 00:43:09 +0000 Subject: a --- azalea-brigadier/src/tree/command_node.rs | 44 +++++++++++-------------------- 1 file changed, 16 insertions(+), 28 deletions(-) (limited to 'azalea-brigadier/src/tree/command_node.rs') diff --git a/azalea-brigadier/src/tree/command_node.rs b/azalea-brigadier/src/tree/command_node.rs index f3be1597..b8f416eb 100644 --- a/azalea-brigadier/src/tree/command_node.rs +++ b/azalea-brigadier/src/tree/command_node.rs @@ -1,6 +1,6 @@ use super::{argument_command_node::ArgumentCommandNode, literal_command_node::LiteralCommandNode}; use crate::{ - arguments::argument_type::{ArgumentType, Types}, + arguments::argument_type::ArgumentType, builder::argument_builder::ArgumentBuilder, command::Command, context::{command_context::CommandContext, command_context_builder::CommandContextBuilder}, @@ -10,29 +10,23 @@ use crate::{ suggestion::{suggestions::Suggestions, suggestions_builder::SuggestionsBuilder}, }; use dyn_clonable::*; -use std::{collections::HashMap, fmt::Debug}; +use std::{any::Any, collections::HashMap, fmt::Debug}; #[derive(Default)] -pub struct BaseCommandNode<'a, S, T> -where - T: ArgumentType, -{ - children: HashMap>, - literals: HashMap>, - arguments: HashMap>, +pub struct BaseCommandNode<'a, S> { + children: HashMap>, + literals: HashMap>, + arguments: HashMap>, requirement: Option<&'a dyn Fn(&S) -> bool>, - redirect: Option<&'a dyn CommandNode>, - modifier: Option<&'a dyn RedirectModifier>, + redirect: Option<&'a dyn CommandNode>, + modifier: Option<&'a dyn RedirectModifier>, forks: bool, - command: Option<&'a dyn Command>, + command: Option<&'a dyn Command>, } -impl BaseCommandNode<'_, S, T> where T: ArgumentType {} +impl BaseCommandNode<'_, S> {} -impl Clone for BaseCommandNode<'_, S, T> -where - T: ArgumentType, -{ +impl Clone for BaseCommandNode<'_, S> { fn clone(&self) -> Self { Self { children: self.children.clone(), @@ -47,10 +41,7 @@ where } } -impl Debug for BaseCommandNode<'_, S, T> -where - T: ArgumentType, -{ +impl Debug for BaseCommandNode<'_, S> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("BaseCommandNode") .field("children", &self.children) @@ -66,23 +57,20 @@ where } #[clonable] -pub trait CommandNode: Clone -where - T: ArgumentType, -{ +pub trait CommandNode: Clone { fn name(&self) -> &str; fn usage_text(&self) -> &str; fn parse( &self, reader: &mut StringReader, - context_builder: CommandContextBuilder, + context_builder: CommandContextBuilder, ) -> Result<(), CommandSyntaxException>; fn list_suggestions( &self, - context: CommandContext, + context: CommandContext, builder: SuggestionsBuilder, ) -> Result; fn is_valid_input(&self, input: &str) -> bool; - fn create_builder(&self) -> dyn ArgumentBuilder; + fn create_builder(&self) -> dyn ArgumentBuilder; fn get_examples(&self) -> Vec; } -- cgit v1.2.3