33use std:: borrow:: Cow ;
44use std:: future:: Future ;
55
6+ use advancement:: Advancement ;
67pub use advancement:: Grant ;
8+ use attribute:: Attribute ;
9+ use bossbar:: Bossbar ;
710pub use target_selector:: { Argument , Sort , TargetSelector } ;
811
12+ use crate :: minecraft:: proxy:: Proxy ;
913use crate :: minecraft:: { Entity , ResourceLocation , Serialize } ;
1014use crate :: Minecraft ;
1115
@@ -23,38 +27,21 @@ pub trait JavaEdition: Minecraft {
2327 ///
2428 /// # Returns
2529 ///
26- /// Returns an [`advancement:: Proxy`] which can be used to execute
30+ /// Returns an [`Proxy`] which can be used to execute
2731 /// advancement-related commands pertaining to the `target`.
28- fn advancement ( & mut self , target : Entity < TargetSelector > ) -> advancement:: Proxy < ' _ , Self >
29- where
30- Self : Sized ,
31- {
32- advancement:: Proxy :: new ( self , vec ! [ "advancement" . into( ) , target. serialize( ) ] )
33- }
32+ fn advancement ( & mut self , target : Entity < TargetSelector > ) -> impl Advancement ;
3433
3534 /// Manage a target's attribute.
3635 ///
3736 /// # Returns
3837 ///
39- /// Returns an [`attribute:: Proxy`] which can be used to execute
38+ /// Returns an [`Proxy`] which can be used to execute
4039 /// advancement-related commands pertaining to the `target`.
4140 fn attribute (
4241 & mut self ,
4342 target : Entity < TargetSelector > ,
4443 attribute : ResourceLocation ,
45- ) -> attribute:: Proxy < ' _ , Self >
46- where
47- Self : Sized ,
48- {
49- attribute:: Proxy :: new (
50- self ,
51- vec ! [
52- "attribute" . into( ) ,
53- target. serialize( ) ,
54- attribute. serialize( ) ,
55- ] ,
56- )
57- }
44+ ) -> impl Attribute ;
5845
5946 /// Adds player to banlist.
6047 ///
@@ -93,24 +80,38 @@ pub trait JavaEdition: Minecraft {
9380 entry_type : Option < banlist:: EntryType > ,
9481 ) -> impl Future < Output = Result < Vec < banlist:: Entry > , banlist:: Error > > + Send ;
9582
96- /// Creates, modifies and lists bossbars.
97- fn bossbar ( & mut self ) -> bossbar :: Proxy < ' _ , Self >
98- where
99- Self : Sized ,
100- {
101- bossbar:: Proxy :: new ( self , vec ! [ "bossbar" . into ( ) ] )
102- }
83+ /// Manage bossbars.
84+ ///
85+ /// # Returns
86+ ///
87+ /// Returns an [`Proxy`] which can be used to execute
88+ /// bossbar-related commands.
89+ fn bossbar ( & mut self ) -> impl Bossbar ;
10390}
10491
10592impl < T > JavaEdition for T
10693where
10794 T : Minecraft + Send ,
10895{
109- /// Adds player to banlist.
110- ///
111- /// # Errors
112- ///
113- /// Returns an [`ban::Error`] on errors.
96+ fn advancement ( & mut self , target : Entity < TargetSelector > ) -> impl Advancement {
97+ Proxy :: new ( self , vec ! [ "advancement" . into( ) , target. serialize( ) ] )
98+ }
99+
100+ fn attribute (
101+ & mut self ,
102+ target : Entity < TargetSelector > ,
103+ attribute : ResourceLocation ,
104+ ) -> impl Attribute {
105+ Proxy :: new (
106+ self ,
107+ vec ! [
108+ "attribute" . into( ) ,
109+ target. serialize( ) ,
110+ attribute. serialize( ) ,
111+ ] ,
112+ )
113+ }
114+
114115 async fn ban (
115116 & mut self ,
116117 target : Entity < TargetSelector > ,
@@ -125,14 +126,6 @@ where
125126 ban:: parse_response ( & self . run_utf8 ( args. join ( " " ) ) . await ?)
126127 }
127128
128- /// Adds IP address to banlist.
129- ///
130- /// Specifies the IP address to be added to the blacklist.
131- /// Can also be a name of an online player, which represents the IP of that player.
132- ///
133- /// # Errors
134- ///
135- /// Returns an [`ban_ip::Error`] on errors.
136129 async fn ban_ip < S > (
137130 & mut self ,
138131 target : ban_ip:: Target ,
@@ -150,11 +143,6 @@ where
150143 ban_ip:: parse_response ( & self . run_utf8 ( args. join ( " " ) ) . await ?)
151144 }
152145
153- /// Return the entries from the ban list.
154- ///
155- /// # Errors
156- ///
157- /// Returns an [`banlist::Error`] on errors.
158146 async fn banlist (
159147 & mut self ,
160148 entry_type : Option < banlist:: EntryType > ,
@@ -167,4 +155,8 @@ where
167155
168156 banlist:: parse_response ( & self . run_utf8 ( args. join ( " " ) ) . await ?)
169157 }
158+
159+ fn bossbar ( & mut self ) -> impl Bossbar {
160+ Proxy :: new ( self , vec ! [ "bossbar" . into( ) ] )
161+ }
170162}
0 commit comments