aboutsummaryrefslogtreecommitdiff
path: root/azalea-brigadier/src/builder
diff options
context:
space:
mode:
authorUbuntu <github@matdoes.dev>2022-01-12 00:40:43 +0000
committerUbuntu <github@matdoes.dev>2022-01-12 00:40:43 +0000
commit270507736af57aae6801dc9eb3c3132139d0d07b (patch)
treea8fa1d1b8d038eb9d7e2061342026d23ddbd9027 /azalea-brigadier/src/builder
parentcc4fe62fc82842e0bde628437a45d55c6a82f1f3 (diff)
downloadazalea-drasl-270507736af57aae6801dc9eb3c3132139d0d07b.tar.xz
a
Diffstat (limited to 'azalea-brigadier/src/builder')
-rw-r--r--azalea-brigadier/src/builder/argument_builder.rs8
-rw-r--r--azalea-brigadier/src/builder/literal_argument_builder.rs15
-rw-r--r--azalea-brigadier/src/builder/required_argument_builder.rs11
3 files changed, 27 insertions, 7 deletions
diff --git a/azalea-brigadier/src/builder/argument_builder.rs b/azalea-brigadier/src/builder/argument_builder.rs
index bd2a2c15..0360b05a 100644
--- a/azalea-brigadier/src/builder/argument_builder.rs
+++ b/azalea-brigadier/src/builder/argument_builder.rs
@@ -1,4 +1,5 @@
use crate::{
+ arguments::argument_type::{ArgumentType, Types},
command::Command,
redirect_modifier::RedirectModifier,
single_redirect_modifier::SingleRedirectModifier,
@@ -8,7 +9,7 @@ use crate::{
pub struct BaseArgumentBuilder<'a, S, T>
where
S: Sized,
- T: Sized,
+ T: Sized + ArgumentType<dyn Types>,
{
arguments: RootCommandNode<'a, S, T>,
command: Option<&'a dyn Command<S, T>>,
@@ -22,7 +23,10 @@ pub trait ArgumentBuilder<S, T> {
fn build(self) -> dyn CommandNode<S, T>;
}
-impl<S, T> BaseArgumentBuilder<'_, S, T> {
+impl<S, T> BaseArgumentBuilder<'_, S, T>
+where
+ T: ArgumentType<dyn Types>,
+{
pub fn then(&mut self, command: dyn CommandNode<S, T>) -> Result<&mut T, String> {
if self.target.is_some() {
return Err("Cannot add children to a redirected node".to_string());
diff --git a/azalea-brigadier/src/builder/literal_argument_builder.rs b/azalea-brigadier/src/builder/literal_argument_builder.rs
index cf9f1ee9..a4cb3f84 100644
--- a/azalea-brigadier/src/builder/literal_argument_builder.rs
+++ b/azalea-brigadier/src/builder/literal_argument_builder.rs
@@ -1,14 +1,23 @@
-use crate::tree::literal_command_node::LiteralCommandNode;
+use crate::{
+ arguments::argument_type::{ArgumentType, Types},
+ tree::literal_command_node::LiteralCommandNode,
+};
use super::argument_builder::BaseArgumentBuilder;
-pub struct LiteralArgumentBuilder<'a, S, T> {
+pub struct LiteralArgumentBuilder<'a, S, T>
+where
+ T: ArgumentType<dyn Types>,
+{
literal: String,
pub base: BaseArgumentBuilder<'a, S, T>,
}
-impl<'a, S, T> LiteralArgumentBuilder<'a, S, T> {
+impl<'a, S, T> LiteralArgumentBuilder<'a, S, T>
+where
+ T: ArgumentType<dyn Types>,
+{
pub fn new(literal: String) -> Self {
Self {
literal,
diff --git a/azalea-brigadier/src/builder/required_argument_builder.rs b/azalea-brigadier/src/builder/required_argument_builder.rs
index 6f6fa8eb..b5f99828 100644
--- a/azalea-brigadier/src/builder/required_argument_builder.rs
+++ b/azalea-brigadier/src/builder/required_argument_builder.rs
@@ -1,11 +1,15 @@
use crate::{
+ arguments::argument_type::{ArgumentType, Types},
suggestion::suggestion_provider::SuggestionProvider,
tree::{argument_command_node::ArgumentCommandNode, command_node::BaseCommandNode},
};
use super::argument_builder::BaseArgumentBuilder;
-pub struct RequiredArgumentBuilder<'a, S, T> {
+pub struct RequiredArgumentBuilder<'a, S, T>
+where
+ T: ArgumentType<dyn Types>,
+{
// private final String name;
// private final ArgumentType<T> type;
// private SuggestionProvider<S> suggestionsProvider = null;
@@ -16,7 +20,10 @@ pub struct RequiredArgumentBuilder<'a, S, T> {
pub base: BaseArgumentBuilder<'a, S, T>,
}
-impl<'a, S, T> RequiredArgumentBuilder<'a, S, T> {
+impl<'a, S, T> RequiredArgumentBuilder<'a, S, T>
+where
+ T: ArgumentType<dyn Types>,
+{
pub fn new(name: String, type_: T) -> Self {
Self {
name,