dragonfly_plugin/server/
helpers.rs

1//! This file is auto-generated by `xtask`. Do not edit manually.
2use crate::{types, Server};
3use tokio::sync::mpsc;
4impl Server {
5    ///Sends a `SendChat` action to the server.
6    pub async fn send_chat(
7        &self,
8        target_uuid: String,
9        message: String,
10    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
11        self.send_action(
12                types::action::Kind::SendChat(types::SendChatAction {
13                    target_uuid,
14                    message,
15                }),
16            )
17            .await
18    }
19    ///Sends a `Teleport` action to the server.
20    pub async fn teleport(
21        &self,
22        player_uuid: String,
23        position: Option<types::Vec3>,
24        rotation: Option<types::Vec3>,
25    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
26        self.send_action(
27                types::action::Kind::Teleport(types::TeleportAction {
28                    player_uuid,
29                    position,
30                    rotation,
31                }),
32            )
33            .await
34    }
35    ///Sends a `Kick` action to the server.
36    pub async fn kick(
37        &self,
38        player_uuid: String,
39        reason: String,
40    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
41        self.send_action(
42                types::action::Kind::Kick(types::KickAction {
43                    player_uuid,
44                    reason,
45                }),
46            )
47            .await
48    }
49    ///Sends a `SetGameMode` action to the server.
50    pub async fn set_game_mode(
51        &self,
52        player_uuid: String,
53        game_mode: i32,
54    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
55        self.send_action(
56                types::action::Kind::SetGameMode(types::SetGameModeAction {
57                    player_uuid,
58                    game_mode,
59                }),
60            )
61            .await
62    }
63    ///Sends a `GiveItem` action to the server.
64    pub async fn give_item(
65        &self,
66        player_uuid: String,
67        item: Option<types::ItemStack>,
68    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
69        self.send_action(
70                types::action::Kind::GiveItem(types::GiveItemAction {
71                    player_uuid,
72                    item,
73                }),
74            )
75            .await
76    }
77    ///Sends a `ClearInventory` action to the server.
78    pub async fn clear_inventory(
79        &self,
80        player_uuid: String,
81    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
82        self.send_action(
83                types::action::Kind::ClearInventory(types::ClearInventoryAction {
84                    player_uuid,
85                }),
86            )
87            .await
88    }
89    ///Sends a `SetHeldItem` action to the server.
90    pub async fn set_held_item(
91        &self,
92        player_uuid: String,
93        main: Option<types::ItemStack>,
94        offhand: Option<types::ItemStack>,
95    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
96        self.send_action(
97                types::action::Kind::SetHeldItem(types::SetHeldItemAction {
98                    player_uuid,
99                    main,
100                    offhand,
101                }),
102            )
103            .await
104    }
105    ///Sends a `SetHealth` action to the server.
106    pub async fn set_health(
107        &self,
108        player_uuid: String,
109        health: f64,
110        max_health: Option<f64>,
111    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
112        self.send_action(
113                types::action::Kind::SetHealth(types::SetHealthAction {
114                    player_uuid,
115                    health,
116                    max_health,
117                }),
118            )
119            .await
120    }
121    ///Sends a `SetFood` action to the server.
122    pub async fn set_food(
123        &self,
124        player_uuid: String,
125        food: i32,
126    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
127        self.send_action(
128                types::action::Kind::SetFood(types::SetFoodAction {
129                    player_uuid,
130                    food,
131                }),
132            )
133            .await
134    }
135    ///Sends a `SetExperience` action to the server.
136    pub async fn set_experience(
137        &self,
138        player_uuid: String,
139        level: Option<i32>,
140        progress: Option<f32>,
141        amount: Option<i32>,
142    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
143        self.send_action(
144                types::action::Kind::SetExperience(types::SetExperienceAction {
145                    player_uuid,
146                    level,
147                    progress,
148                    amount,
149                }),
150            )
151            .await
152    }
153    ///Sends a `SetVelocity` action to the server.
154    pub async fn set_velocity(
155        &self,
156        player_uuid: String,
157        velocity: Option<types::Vec3>,
158    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
159        self.send_action(
160                types::action::Kind::SetVelocity(types::SetVelocityAction {
161                    player_uuid,
162                    velocity,
163                }),
164            )
165            .await
166    }
167    ///Sends a `AddEffect` action to the server.
168    pub async fn add_effect(
169        &self,
170        player_uuid: String,
171        effect_type: i32,
172        level: i32,
173        duration_ms: i64,
174        show_particles: bool,
175    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
176        self.send_action(
177                types::action::Kind::AddEffect(types::AddEffectAction {
178                    player_uuid,
179                    effect_type,
180                    level,
181                    duration_ms,
182                    show_particles,
183                }),
184            )
185            .await
186    }
187    ///Sends a `RemoveEffect` action to the server.
188    pub async fn remove_effect(
189        &self,
190        player_uuid: String,
191        effect_type: i32,
192    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
193        self.send_action(
194                types::action::Kind::RemoveEffect(types::RemoveEffectAction {
195                    player_uuid,
196                    effect_type,
197                }),
198            )
199            .await
200    }
201    ///Sends a `SendTitle` action to the server.
202    pub async fn send_title(
203        &self,
204        player_uuid: String,
205        title: String,
206        subtitle: Option<String>,
207        fade_in_ms: Option<i64>,
208        duration_ms: Option<i64>,
209        fade_out_ms: Option<i64>,
210    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
211        self.send_action(
212                types::action::Kind::SendTitle(types::SendTitleAction {
213                    player_uuid,
214                    title,
215                    subtitle,
216                    fade_in_ms,
217                    duration_ms,
218                    fade_out_ms,
219                }),
220            )
221            .await
222    }
223    ///Sends a `SendPopup` action to the server.
224    pub async fn send_popup(
225        &self,
226        player_uuid: String,
227        message: String,
228    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
229        self.send_action(
230                types::action::Kind::SendPopup(types::SendPopupAction {
231                    player_uuid,
232                    message,
233                }),
234            )
235            .await
236    }
237    ///Sends a `SendTip` action to the server.
238    pub async fn send_tip(
239        &self,
240        player_uuid: String,
241        message: String,
242    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
243        self.send_action(
244                types::action::Kind::SendTip(types::SendTipAction {
245                    player_uuid,
246                    message,
247                }),
248            )
249            .await
250    }
251    ///Sends a `PlaySound` action to the server.
252    pub async fn play_sound(
253        &self,
254        player_uuid: String,
255        sound: i32,
256        position: Option<types::Vec3>,
257        volume: Option<f32>,
258        pitch: Option<f32>,
259    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
260        self.send_action(
261                types::action::Kind::PlaySound(types::PlaySoundAction {
262                    player_uuid,
263                    sound,
264                    position,
265                    volume,
266                    pitch,
267                }),
268            )
269            .await
270    }
271    ///Sends a `ExecuteCommand` action to the server.
272    pub async fn execute_command(
273        &self,
274        player_uuid: String,
275        command: String,
276    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
277        self.send_action(
278                types::action::Kind::ExecuteCommand(types::ExecuteCommandAction {
279                    player_uuid,
280                    command,
281                }),
282            )
283            .await
284    }
285    ///Sends a `WorldSetDefaultGameMode` action to the server.
286    pub async fn world_set_default_game_mode(
287        &self,
288        world: Option<types::WorldRef>,
289        game_mode: i32,
290    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
291        self.send_action(
292                types::action::Kind::WorldSetDefaultGameMode(types::WorldSetDefaultGameModeAction {
293                    world,
294                    game_mode,
295                }),
296            )
297            .await
298    }
299    ///Sends a `WorldSetDifficulty` action to the server.
300    pub async fn world_set_difficulty(
301        &self,
302        world: Option<types::WorldRef>,
303        difficulty: i32,
304    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
305        self.send_action(
306                types::action::Kind::WorldSetDifficulty(types::WorldSetDifficultyAction {
307                    world,
308                    difficulty,
309                }),
310            )
311            .await
312    }
313    ///Sends a `WorldSetTickRange` action to the server.
314    pub async fn world_set_tick_range(
315        &self,
316        world: Option<types::WorldRef>,
317        tick_range: i32,
318    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
319        self.send_action(
320                types::action::Kind::WorldSetTickRange(types::WorldSetTickRangeAction {
321                    world,
322                    tick_range,
323                }),
324            )
325            .await
326    }
327    ///Sends a `WorldSetBlock` action to the server.
328    pub async fn world_set_block(
329        &self,
330        world: Option<types::WorldRef>,
331        position: Option<types::BlockPos>,
332        block: Option<types::BlockState>,
333    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
334        self.send_action(
335                types::action::Kind::WorldSetBlock(types::WorldSetBlockAction {
336                    world,
337                    position,
338                    block,
339                }),
340            )
341            .await
342    }
343    ///Sends a `WorldPlaySound` action to the server.
344    pub async fn world_play_sound(
345        &self,
346        world: Option<types::WorldRef>,
347        sound: i32,
348        position: Option<types::Vec3>,
349    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
350        self.send_action(
351                types::action::Kind::WorldPlaySound(types::WorldPlaySoundAction {
352                    world,
353                    sound,
354                    position,
355                }),
356            )
357            .await
358    }
359    ///Sends a `WorldAddParticle` action to the server.
360    pub async fn world_add_particle(
361        &self,
362        world: Option<types::WorldRef>,
363        position: Option<types::Vec3>,
364        particle: i32,
365        block: Option<types::BlockState>,
366        face: Option<i32>,
367    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
368        self.send_action(
369                types::action::Kind::WorldAddParticle(types::WorldAddParticleAction {
370                    world,
371                    position,
372                    particle,
373                    block,
374                    face,
375                }),
376            )
377            .await
378    }
379    ///Sends a `WorldQueryEntities` action to the server.
380    pub async fn world_query_entities(
381        &self,
382        world: Option<types::WorldRef>,
383    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
384        self.send_action(
385                types::action::Kind::WorldQueryEntities(types::WorldQueryEntitiesAction {
386                    world,
387                }),
388            )
389            .await
390    }
391    ///Sends a `WorldQueryPlayers` action to the server.
392    pub async fn world_query_players(
393        &self,
394        world: Option<types::WorldRef>,
395    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
396        self.send_action(
397                types::action::Kind::WorldQueryPlayers(types::WorldQueryPlayersAction {
398                    world,
399                }),
400            )
401            .await
402    }
403    ///Sends a `WorldQueryEntitiesWithin` action to the server.
404    pub async fn world_query_entities_within(
405        &self,
406        world: Option<types::WorldRef>,
407        r#box: Option<types::BBox>,
408    ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
409        self.send_action(
410                types::action::Kind::WorldQueryEntitiesWithin(types::WorldQueryEntitiesWithinAction {
411                    world,
412                    r#box,
413                }),
414            )
415            .await
416    }
417}