work a bit on brigadier

This commit is contained in:
Ubuntu 2022-01-11 00:42:30 +00:00
parent fec7a2bfed
commit cb4d871f6f
4 changed files with 25 additions and 11 deletions

View file

@ -1,3 +1,4 @@
use super::bool_argument_type::BoolArgumentType;
use crate::{
context::command_context::CommandContext,
exceptions::command_syntax_exception::CommandSyntaxException,
@ -5,12 +6,27 @@ use crate::{
suggestion::{suggestions::Suggestions, suggestions_builder::SuggestionsBuilder},
};
pub trait ArgumentResult {}
pub enum DefaultArguments {
Bool(BoolArgumentType),
}
pub trait ArgumentType<T>
where
T: ArgumentResult,
{
/*
define_arguments! {
Entity(EntityArgumentType)
}
===
enum CustomArguments {
Entity(EntityArgumentType)
}
enum BrigadierArguments {
BuiltIn(DefaultArguments)
Custom(CustomArguments)
}
*/
pub trait ArgumentType<T> {
// T parse(StringReader reader) throws CommandSyntaxException;
// default <S> CompletableFuture<Suggestions> listSuggestions(final CommandContext<S> context, final SuggestionsBuilder builder) {

View file

@ -2,7 +2,7 @@ use crate::context::command_context::CommandContext;
use super::argument_type::ArgumentType;
struct BoolArgumentType {}
pub struct BoolArgumentType {}
impl ArgumentType<bool> for BoolArgumentType {}

View file

@ -1,10 +1,8 @@
use std::collections::HashMap;
use crate::{
arguments::argument_type::{ArgumentResult, ArgumentType},
command::Command,
command_dispatcher::CommandDispatcher,
redirect_modifier::RedirectModifier,
arguments::argument_type::ArgumentType, command::Command,
command_dispatcher::CommandDispatcher, redirect_modifier::RedirectModifier,
tree::command_node::CommandNode,
};

View file

@ -16,7 +16,7 @@ use super::{argument_command_node::ArgumentCommandNode, literal_command_node::Li
pub struct BaseCommandNode<S> {
children: HashMap<String, dyn CommandNode<S>>,
literals: HashMap<String, LiteralCommandNode<S>>,
arguments: HashMap<String, ArgumentCommandNode<S, dyn ArgumentType<dyn ArgumentResult>>>,
arguments: HashMap<String, ArgumentCommandNode<S, dyn ArgumentType<ArgumentResult>>>,
requirement: Option<dyn Fn(&S) -> bool>,
redirect: Option<dyn CommandNode<S>>,
modifier: Option<dyn RedirectModifier<S>>,