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