1use crate::{types, Server};
3use tokio::sync::mpsc;
4impl Server {
5 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 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 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 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 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 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 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 pub async fn player_set_armour(
93 &self,
94 player_uuid: String,
95 helmet: impl Into<Option<types::ItemStack>>,
96 chestplate: impl Into<Option<types::ItemStack>>,
97 leggings: impl Into<Option<types::ItemStack>>,
98 boots: impl Into<Option<types::ItemStack>>,
99 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
100 self.send_action(types::action::Kind::PlayerSetArmour(
101 types::PlayerSetArmourAction {
102 player_uuid,
103 helmet: helmet.into(),
104 chestplate: chestplate.into(),
105 leggings: leggings.into(),
106 boots: boots.into(),
107 },
108 ))
109 .await
110 }
111 pub async fn player_open_block_container(
113 &self,
114 player_uuid: String,
115 position: impl Into<Option<types::BlockPos>>,
116 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
117 self.send_action(types::action::Kind::PlayerOpenBlockContainer(
118 types::PlayerOpenBlockContainerAction {
119 player_uuid,
120 position: position.into(),
121 },
122 ))
123 .await
124 }
125 pub async fn player_drop_item(
127 &self,
128 player_uuid: String,
129 item: impl Into<Option<types::ItemStack>>,
130 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
131 self.send_action(types::action::Kind::PlayerDropItem(
132 types::PlayerDropItemAction {
133 player_uuid,
134 item: item.into(),
135 },
136 ))
137 .await
138 }
139 pub async fn player_set_item_cooldown(
141 &self,
142 player_uuid: String,
143 item: impl Into<Option<types::ItemStack>>,
144 duration_ms: i64,
145 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
146 self.send_action(types::action::Kind::PlayerSetItemCooldown(
147 types::PlayerSetItemCooldownAction {
148 player_uuid,
149 item: item.into(),
150 duration_ms,
151 },
152 ))
153 .await
154 }
155 pub async fn set_health(
157 &self,
158 player_uuid: String,
159 health: f64,
160 max_health: impl Into<Option<f64>>,
161 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
162 self.send_action(types::action::Kind::SetHealth(types::SetHealthAction {
163 player_uuid,
164 health,
165 max_health: max_health.into(),
166 }))
167 .await
168 }
169 pub async fn set_food(
171 &self,
172 player_uuid: String,
173 food: i32,
174 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
175 self.send_action(types::action::Kind::SetFood(types::SetFoodAction {
176 player_uuid,
177 food,
178 }))
179 .await
180 }
181 pub async fn set_experience(
183 &self,
184 player_uuid: String,
185 level: impl Into<Option<i32>>,
186 progress: impl Into<Option<f32>>,
187 amount: impl Into<Option<i32>>,
188 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
189 self.send_action(types::action::Kind::SetExperience(
190 types::SetExperienceAction {
191 player_uuid,
192 level: level.into(),
193 progress: progress.into(),
194 amount: amount.into(),
195 },
196 ))
197 .await
198 }
199 pub async fn set_velocity(
201 &self,
202 player_uuid: String,
203 velocity: impl Into<Option<types::Vec3>>,
204 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
205 self.send_action(types::action::Kind::SetVelocity(types::SetVelocityAction {
206 player_uuid,
207 velocity: velocity.into(),
208 }))
209 .await
210 }
211 pub async fn add_effect(
213 &self,
214 player_uuid: String,
215 effect_type: types::EffectType,
216 level: i32,
217 duration_ms: i64,
218 show_particles: bool,
219 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
220 self.send_action(types::action::Kind::AddEffect(types::AddEffectAction {
221 player_uuid,
222 effect_type: effect_type.into(),
223 level,
224 duration_ms,
225 show_particles,
226 }))
227 .await
228 }
229 pub async fn remove_effect(
231 &self,
232 player_uuid: String,
233 effect_type: types::EffectType,
234 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
235 self.send_action(types::action::Kind::RemoveEffect(
236 types::RemoveEffectAction {
237 player_uuid,
238 effect_type: effect_type.into(),
239 },
240 ))
241 .await
242 }
243 pub async fn send_title(
245 &self,
246 player_uuid: String,
247 title: String,
248 subtitle: impl Into<Option<String>>,
249 fade_in_ms: impl Into<Option<i64>>,
250 duration_ms: impl Into<Option<i64>>,
251 fade_out_ms: impl Into<Option<i64>>,
252 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
253 self.send_action(types::action::Kind::SendTitle(types::SendTitleAction {
254 player_uuid,
255 title,
256 subtitle: subtitle.into(),
257 fade_in_ms: fade_in_ms.into(),
258 duration_ms: duration_ms.into(),
259 fade_out_ms: fade_out_ms.into(),
260 }))
261 .await
262 }
263 pub async fn send_popup(
265 &self,
266 player_uuid: String,
267 message: String,
268 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
269 self.send_action(types::action::Kind::SendPopup(types::SendPopupAction {
270 player_uuid,
271 message,
272 }))
273 .await
274 }
275 pub async fn send_tip(
277 &self,
278 player_uuid: String,
279 message: String,
280 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
281 self.send_action(types::action::Kind::SendTip(types::SendTipAction {
282 player_uuid,
283 message,
284 }))
285 .await
286 }
287 pub async fn player_send_toast(
289 &self,
290 player_uuid: String,
291 title: String,
292 message: String,
293 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
294 self.send_action(types::action::Kind::PlayerSendToast(
295 types::PlayerSendToastAction {
296 player_uuid,
297 title,
298 message,
299 },
300 ))
301 .await
302 }
303 pub async fn player_send_jukebox_popup(
305 &self,
306 player_uuid: String,
307 message: String,
308 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
309 self.send_action(types::action::Kind::PlayerSendJukeboxPopup(
310 types::PlayerSendJukeboxPopupAction {
311 player_uuid,
312 message,
313 },
314 ))
315 .await
316 }
317 pub async fn player_show_coordinates(
319 &self,
320 player_uuid: String,
321 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
322 self.send_action(types::action::Kind::PlayerShowCoordinates(
323 types::PlayerShowCoordinatesAction { player_uuid },
324 ))
325 .await
326 }
327 pub async fn player_hide_coordinates(
329 &self,
330 player_uuid: String,
331 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
332 self.send_action(types::action::Kind::PlayerHideCoordinates(
333 types::PlayerHideCoordinatesAction { player_uuid },
334 ))
335 .await
336 }
337 pub async fn player_enable_instant_respawn(
339 &self,
340 player_uuid: String,
341 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
342 self.send_action(types::action::Kind::PlayerEnableInstantRespawn(
343 types::PlayerEnableInstantRespawnAction { player_uuid },
344 ))
345 .await
346 }
347 pub async fn player_disable_instant_respawn(
349 &self,
350 player_uuid: String,
351 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
352 self.send_action(types::action::Kind::PlayerDisableInstantRespawn(
353 types::PlayerDisableInstantRespawnAction { player_uuid },
354 ))
355 .await
356 }
357 pub async fn player_set_name_tag(
359 &self,
360 player_uuid: String,
361 name_tag: String,
362 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
363 self.send_action(types::action::Kind::PlayerSetNameTag(
364 types::PlayerSetNameTagAction {
365 player_uuid,
366 name_tag,
367 },
368 ))
369 .await
370 }
371 pub async fn player_set_score_tag(
373 &self,
374 player_uuid: String,
375 score_tag: String,
376 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
377 self.send_action(types::action::Kind::PlayerSetScoreTag(
378 types::PlayerSetScoreTagAction {
379 player_uuid,
380 score_tag,
381 },
382 ))
383 .await
384 }
385 pub async fn play_sound(
387 &self,
388 player_uuid: String,
389 sound: types::Sound,
390 position: impl Into<Option<types::Vec3>>,
391 volume: impl Into<Option<f32>>,
392 pitch: impl Into<Option<f32>>,
393 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
394 self.send_action(types::action::Kind::PlaySound(types::PlaySoundAction {
395 player_uuid,
396 sound: sound.into(),
397 position: position.into(),
398 volume: volume.into(),
399 pitch: pitch.into(),
400 }))
401 .await
402 }
403 pub async fn player_show_particle(
405 &self,
406 player_uuid: String,
407 position: impl Into<Option<types::Vec3>>,
408 particle: types::ParticleType,
409 block: impl Into<Option<types::BlockState>>,
410 face: impl Into<Option<i32>>,
411 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
412 self.send_action(types::action::Kind::PlayerShowParticle(
413 types::PlayerShowParticleAction {
414 player_uuid,
415 position: position.into(),
416 particle: particle.into(),
417 block: block.into(),
418 face: face.into(),
419 },
420 ))
421 .await
422 }
423 pub async fn player_send_scoreboard(
425 &self,
426 player_uuid: String,
427 title: String,
428 lines: Vec<String>,
429 padding: impl Into<Option<bool>>,
430 descending: impl Into<Option<bool>>,
431 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
432 self.send_action(types::action::Kind::PlayerSendScoreboard(
433 types::PlayerSendScoreboardAction {
434 player_uuid,
435 title,
436 lines,
437 padding: padding.into(),
438 descending: descending.into(),
439 },
440 ))
441 .await
442 }
443 pub async fn player_remove_scoreboard(
445 &self,
446 player_uuid: String,
447 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
448 self.send_action(types::action::Kind::PlayerRemoveScoreboard(
449 types::PlayerRemoveScoreboardAction { player_uuid },
450 ))
451 .await
452 }
453 pub async fn player_send_menu_form(
455 &self,
456 player_uuid: String,
457 title: String,
458 body: impl Into<Option<String>>,
459 buttons: Vec<String>,
460 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
461 self.send_action(types::action::Kind::PlayerSendMenuForm(
462 types::PlayerSendMenuFormAction {
463 player_uuid,
464 title,
465 body: body.into(),
466 buttons,
467 },
468 ))
469 .await
470 }
471 pub async fn player_send_modal_form(
473 &self,
474 player_uuid: String,
475 title: String,
476 body: String,
477 yes_text: String,
478 no_text: String,
479 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
480 self.send_action(types::action::Kind::PlayerSendModalForm(
481 types::PlayerSendModalFormAction {
482 player_uuid,
483 title,
484 body,
485 yes_text,
486 no_text,
487 },
488 ))
489 .await
490 }
491 pub async fn player_send_dialogue(
493 &self,
494 player_uuid: String,
495 title: String,
496 body: impl Into<Option<String>>,
497 buttons: Vec<String>,
498 entity: impl Into<Option<types::EntityRef>>,
499 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
500 self.send_action(types::action::Kind::PlayerSendDialogue(
501 types::PlayerSendDialogueAction {
502 player_uuid,
503 title,
504 body: body.into(),
505 buttons,
506 entity: entity.into(),
507 },
508 ))
509 .await
510 }
511 pub async fn player_close_dialogue(
513 &self,
514 player_uuid: String,
515 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
516 self.send_action(types::action::Kind::PlayerCloseDialogue(
517 types::PlayerCloseDialogueAction { player_uuid },
518 ))
519 .await
520 }
521 pub async fn player_close_form(
523 &self,
524 player_uuid: String,
525 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
526 self.send_action(types::action::Kind::PlayerCloseForm(
527 types::PlayerCloseFormAction { player_uuid },
528 ))
529 .await
530 }
531 pub async fn execute_command(
533 &self,
534 player_uuid: String,
535 command: String,
536 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
537 self.send_action(types::action::Kind::ExecuteCommand(
538 types::ExecuteCommandAction {
539 player_uuid,
540 command,
541 },
542 ))
543 .await
544 }
545 pub async fn player_start_sprinting(
547 &self,
548 player_uuid: String,
549 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
550 self.send_action(types::action::Kind::PlayerStartSprinting(
551 types::PlayerStartSprintingAction { player_uuid },
552 ))
553 .await
554 }
555 pub async fn player_stop_sprinting(
557 &self,
558 player_uuid: String,
559 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
560 self.send_action(types::action::Kind::PlayerStopSprinting(
561 types::PlayerStopSprintingAction { player_uuid },
562 ))
563 .await
564 }
565 pub async fn player_start_sneaking(
567 &self,
568 player_uuid: String,
569 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
570 self.send_action(types::action::Kind::PlayerStartSneaking(
571 types::PlayerStartSneakingAction { player_uuid },
572 ))
573 .await
574 }
575 pub async fn player_stop_sneaking(
577 &self,
578 player_uuid: String,
579 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
580 self.send_action(types::action::Kind::PlayerStopSneaking(
581 types::PlayerStopSneakingAction { player_uuid },
582 ))
583 .await
584 }
585 pub async fn player_start_swimming(
587 &self,
588 player_uuid: String,
589 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
590 self.send_action(types::action::Kind::PlayerStartSwimming(
591 types::PlayerStartSwimmingAction { player_uuid },
592 ))
593 .await
594 }
595 pub async fn player_stop_swimming(
597 &self,
598 player_uuid: String,
599 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
600 self.send_action(types::action::Kind::PlayerStopSwimming(
601 types::PlayerStopSwimmingAction { player_uuid },
602 ))
603 .await
604 }
605 pub async fn player_start_crawling(
607 &self,
608 player_uuid: String,
609 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
610 self.send_action(types::action::Kind::PlayerStartCrawling(
611 types::PlayerStartCrawlingAction { player_uuid },
612 ))
613 .await
614 }
615 pub async fn player_stop_crawling(
617 &self,
618 player_uuid: String,
619 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
620 self.send_action(types::action::Kind::PlayerStopCrawling(
621 types::PlayerStopCrawlingAction { player_uuid },
622 ))
623 .await
624 }
625 pub async fn player_start_gliding(
627 &self,
628 player_uuid: String,
629 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
630 self.send_action(types::action::Kind::PlayerStartGliding(
631 types::PlayerStartGlidingAction { player_uuid },
632 ))
633 .await
634 }
635 pub async fn player_stop_gliding(
637 &self,
638 player_uuid: String,
639 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
640 self.send_action(types::action::Kind::PlayerStopGliding(
641 types::PlayerStopGlidingAction { player_uuid },
642 ))
643 .await
644 }
645 pub async fn player_start_flying(
647 &self,
648 player_uuid: String,
649 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
650 self.send_action(types::action::Kind::PlayerStartFlying(
651 types::PlayerStartFlyingAction { player_uuid },
652 ))
653 .await
654 }
655 pub async fn player_stop_flying(
657 &self,
658 player_uuid: String,
659 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
660 self.send_action(types::action::Kind::PlayerStopFlying(
661 types::PlayerStopFlyingAction { player_uuid },
662 ))
663 .await
664 }
665 pub async fn player_set_immobile(
667 &self,
668 player_uuid: String,
669 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
670 self.send_action(types::action::Kind::PlayerSetImmobile(
671 types::PlayerSetImmobileAction { player_uuid },
672 ))
673 .await
674 }
675 pub async fn player_set_mobile(
677 &self,
678 player_uuid: String,
679 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
680 self.send_action(types::action::Kind::PlayerSetMobile(
681 types::PlayerSetMobileAction { player_uuid },
682 ))
683 .await
684 }
685 pub async fn player_set_speed(
687 &self,
688 player_uuid: String,
689 speed: f64,
690 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
691 self.send_action(types::action::Kind::PlayerSetSpeed(
692 types::PlayerSetSpeedAction { player_uuid, speed },
693 ))
694 .await
695 }
696 pub async fn player_set_flight_speed(
698 &self,
699 player_uuid: String,
700 flight_speed: f64,
701 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
702 self.send_action(types::action::Kind::PlayerSetFlightSpeed(
703 types::PlayerSetFlightSpeedAction {
704 player_uuid,
705 flight_speed,
706 },
707 ))
708 .await
709 }
710 pub async fn player_set_vertical_flight_speed(
712 &self,
713 player_uuid: String,
714 vertical_flight_speed: f64,
715 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
716 self.send_action(types::action::Kind::PlayerSetVerticalFlightSpeed(
717 types::PlayerSetVerticalFlightSpeedAction {
718 player_uuid,
719 vertical_flight_speed,
720 },
721 ))
722 .await
723 }
724 pub async fn player_set_absorption(
726 &self,
727 player_uuid: String,
728 absorption: f64,
729 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
730 self.send_action(types::action::Kind::PlayerSetAbsorption(
731 types::PlayerSetAbsorptionAction {
732 player_uuid,
733 absorption,
734 },
735 ))
736 .await
737 }
738 pub async fn player_set_on_fire(
740 &self,
741 player_uuid: String,
742 duration_ms: i64,
743 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
744 self.send_action(types::action::Kind::PlayerSetOnFire(
745 types::PlayerSetOnFireAction {
746 player_uuid,
747 duration_ms,
748 },
749 ))
750 .await
751 }
752 pub async fn player_extinguish(
754 &self,
755 player_uuid: String,
756 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
757 self.send_action(types::action::Kind::PlayerExtinguish(
758 types::PlayerExtinguishAction { player_uuid },
759 ))
760 .await
761 }
762 pub async fn player_set_invisible(
764 &self,
765 player_uuid: String,
766 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
767 self.send_action(types::action::Kind::PlayerSetInvisible(
768 types::PlayerSetInvisibleAction { player_uuid },
769 ))
770 .await
771 }
772 pub async fn player_set_visible(
774 &self,
775 player_uuid: String,
776 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
777 self.send_action(types::action::Kind::PlayerSetVisible(
778 types::PlayerSetVisibleAction { player_uuid },
779 ))
780 .await
781 }
782 pub async fn player_set_scale(
784 &self,
785 player_uuid: String,
786 scale: f64,
787 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
788 self.send_action(types::action::Kind::PlayerSetScale(
789 types::PlayerSetScaleAction { player_uuid, scale },
790 ))
791 .await
792 }
793 pub async fn player_set_held_slot(
795 &self,
796 player_uuid: String,
797 slot: i32,
798 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
799 self.send_action(types::action::Kind::PlayerSetHeldSlot(
800 types::PlayerSetHeldSlotAction { player_uuid, slot },
801 ))
802 .await
803 }
804 pub async fn player_respawn(
806 &self,
807 player_uuid: String,
808 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
809 self.send_action(types::action::Kind::PlayerRespawn(
810 types::PlayerRespawnAction { player_uuid },
811 ))
812 .await
813 }
814 pub async fn player_transfer(
816 &self,
817 player_uuid: String,
818 address: impl Into<Option<types::Address>>,
819 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
820 self.send_action(types::action::Kind::PlayerTransfer(
821 types::PlayerTransferAction {
822 player_uuid,
823 address: address.into(),
824 },
825 ))
826 .await
827 }
828 pub async fn player_knock_back(
830 &self,
831 player_uuid: String,
832 source: impl Into<Option<types::Vec3>>,
833 force: f64,
834 height: f64,
835 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
836 self.send_action(types::action::Kind::PlayerKnockBack(
837 types::PlayerKnockBackAction {
838 player_uuid,
839 source: source.into(),
840 force,
841 height,
842 },
843 ))
844 .await
845 }
846 pub async fn player_swing_arm(
848 &self,
849 player_uuid: String,
850 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
851 self.send_action(types::action::Kind::PlayerSwingArm(
852 types::PlayerSwingArmAction { player_uuid },
853 ))
854 .await
855 }
856 pub async fn player_punch_air(
858 &self,
859 player_uuid: String,
860 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
861 self.send_action(types::action::Kind::PlayerPunchAir(
862 types::PlayerPunchAirAction { player_uuid },
863 ))
864 .await
865 }
866 pub async fn player_send_boss_bar(
868 &self,
869 player_uuid: String,
870 text: String,
871 health_percentage: impl Into<Option<f32>>,
872 colour: impl Into<Option<types::BossBarColour>>,
873 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
874 self.send_action(types::action::Kind::PlayerSendBossBar(
875 types::PlayerSendBossBarAction {
876 player_uuid,
877 text,
878 health_percentage: health_percentage.into(),
879 colour: colour.into().map(|x| x.into()),
880 },
881 ))
882 .await
883 }
884 pub async fn player_remove_boss_bar(
886 &self,
887 player_uuid: String,
888 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
889 self.send_action(types::action::Kind::PlayerRemoveBossBar(
890 types::PlayerRemoveBossBarAction { player_uuid },
891 ))
892 .await
893 }
894 pub async fn player_show_hud_element(
896 &self,
897 player_uuid: String,
898 element: types::HudElement,
899 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
900 self.send_action(types::action::Kind::PlayerShowHudElement(
901 types::PlayerShowHudElementAction {
902 player_uuid,
903 element: element.into(),
904 },
905 ))
906 .await
907 }
908 pub async fn player_hide_hud_element(
910 &self,
911 player_uuid: String,
912 element: types::HudElement,
913 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
914 self.send_action(types::action::Kind::PlayerHideHudElement(
915 types::PlayerHideHudElementAction {
916 player_uuid,
917 element: element.into(),
918 },
919 ))
920 .await
921 }
922 pub async fn player_open_sign(
924 &self,
925 player_uuid: String,
926 position: impl Into<Option<types::BlockPos>>,
927 front_side: bool,
928 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
929 self.send_action(types::action::Kind::PlayerOpenSign(
930 types::PlayerOpenSignAction {
931 player_uuid,
932 position: position.into(),
933 front_side,
934 },
935 ))
936 .await
937 }
938 pub async fn player_edit_sign(
940 &self,
941 player_uuid: String,
942 position: impl Into<Option<types::BlockPos>>,
943 front_text: String,
944 back_text: String,
945 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
946 self.send_action(types::action::Kind::PlayerEditSign(
947 types::PlayerEditSignAction {
948 player_uuid,
949 position: position.into(),
950 front_text,
951 back_text,
952 },
953 ))
954 .await
955 }
956 pub async fn player_turn_lectern_page(
958 &self,
959 player_uuid: String,
960 position: impl Into<Option<types::BlockPos>>,
961 page: i32,
962 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
963 self.send_action(types::action::Kind::PlayerTurnLecternPage(
964 types::PlayerTurnLecternPageAction {
965 player_uuid,
966 position: position.into(),
967 page,
968 },
969 ))
970 .await
971 }
972 pub async fn player_hide_player(
974 &self,
975 player_uuid: String,
976 target_uuid: String,
977 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
978 self.send_action(types::action::Kind::PlayerHidePlayer(
979 types::PlayerHidePlayerAction {
980 player_uuid,
981 target_uuid,
982 },
983 ))
984 .await
985 }
986 pub async fn player_show_player(
988 &self,
989 player_uuid: String,
990 target_uuid: String,
991 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
992 self.send_action(types::action::Kind::PlayerShowPlayer(
993 types::PlayerShowPlayerAction {
994 player_uuid,
995 target_uuid,
996 },
997 ))
998 .await
999 }
1000 pub async fn player_remove_all_debug_shapes(
1002 &self,
1003 player_uuid: String,
1004 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1005 self.send_action(types::action::Kind::PlayerRemoveAllDebugShapes(
1006 types::PlayerRemoveAllDebugShapesAction { player_uuid },
1007 ))
1008 .await
1009 }
1010 pub async fn world_set_default_game_mode(
1012 &self,
1013 world: impl Into<Option<types::WorldRef>>,
1014 game_mode: types::GameMode,
1015 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1016 self.send_action(types::action::Kind::WorldSetDefaultGameMode(
1017 types::WorldSetDefaultGameModeAction {
1018 world: world.into(),
1019 game_mode: game_mode.into(),
1020 },
1021 ))
1022 .await
1023 }
1024 pub async fn world_set_difficulty(
1026 &self,
1027 world: impl Into<Option<types::WorldRef>>,
1028 difficulty: types::Difficulty,
1029 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1030 self.send_action(types::action::Kind::WorldSetDifficulty(
1031 types::WorldSetDifficultyAction {
1032 world: world.into(),
1033 difficulty: difficulty.into(),
1034 },
1035 ))
1036 .await
1037 }
1038 pub async fn world_set_tick_range(
1040 &self,
1041 world: impl Into<Option<types::WorldRef>>,
1042 tick_range: i32,
1043 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1044 self.send_action(types::action::Kind::WorldSetTickRange(
1045 types::WorldSetTickRangeAction {
1046 world: world.into(),
1047 tick_range,
1048 },
1049 ))
1050 .await
1051 }
1052 pub async fn world_set_block(
1054 &self,
1055 world: impl Into<Option<types::WorldRef>>,
1056 position: impl Into<Option<types::BlockPos>>,
1057 block: impl Into<Option<types::BlockState>>,
1058 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1059 self.send_action(types::action::Kind::WorldSetBlock(
1060 types::WorldSetBlockAction {
1061 world: world.into(),
1062 position: position.into(),
1063 block: block.into(),
1064 },
1065 ))
1066 .await
1067 }
1068 pub async fn world_play_sound(
1070 &self,
1071 world: impl Into<Option<types::WorldRef>>,
1072 sound: types::Sound,
1073 position: impl Into<Option<types::Vec3>>,
1074 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1075 self.send_action(types::action::Kind::WorldPlaySound(
1076 types::WorldPlaySoundAction {
1077 world: world.into(),
1078 sound: sound.into(),
1079 position: position.into(),
1080 },
1081 ))
1082 .await
1083 }
1084 pub async fn world_add_particle(
1086 &self,
1087 world: impl Into<Option<types::WorldRef>>,
1088 position: impl Into<Option<types::Vec3>>,
1089 particle: types::ParticleType,
1090 block: impl Into<Option<types::BlockState>>,
1091 face: impl Into<Option<i32>>,
1092 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1093 self.send_action(types::action::Kind::WorldAddParticle(
1094 types::WorldAddParticleAction {
1095 world: world.into(),
1096 position: position.into(),
1097 particle: particle.into(),
1098 block: block.into(),
1099 face: face.into(),
1100 },
1101 ))
1102 .await
1103 }
1104 pub async fn world_set_time(
1106 &self,
1107 world: impl Into<Option<types::WorldRef>>,
1108 time: i32,
1109 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1110 self.send_action(types::action::Kind::WorldSetTime(
1111 types::WorldSetTimeAction {
1112 world: world.into(),
1113 time,
1114 },
1115 ))
1116 .await
1117 }
1118 pub async fn world_stop_time(
1120 &self,
1121 world: impl Into<Option<types::WorldRef>>,
1122 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1123 self.send_action(types::action::Kind::WorldStopTime(
1124 types::WorldStopTimeAction {
1125 world: world.into(),
1126 },
1127 ))
1128 .await
1129 }
1130 pub async fn world_start_time(
1132 &self,
1133 world: impl Into<Option<types::WorldRef>>,
1134 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1135 self.send_action(types::action::Kind::WorldStartTime(
1136 types::WorldStartTimeAction {
1137 world: world.into(),
1138 },
1139 ))
1140 .await
1141 }
1142 pub async fn world_set_spawn(
1144 &self,
1145 world: impl Into<Option<types::WorldRef>>,
1146 spawn: impl Into<Option<types::BlockPos>>,
1147 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1148 self.send_action(types::action::Kind::WorldSetSpawn(
1149 types::WorldSetSpawnAction {
1150 world: world.into(),
1151 spawn: spawn.into(),
1152 },
1153 ))
1154 .await
1155 }
1156 pub async fn world_set_biome(
1158 &self,
1159 world: impl Into<Option<types::WorldRef>>,
1160 position: impl Into<Option<types::BlockPos>>,
1161 biome_id: String,
1162 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1163 self.send_action(types::action::Kind::WorldSetBiome(
1164 types::WorldSetBiomeAction {
1165 world: world.into(),
1166 position: position.into(),
1167 biome_id,
1168 },
1169 ))
1170 .await
1171 }
1172 pub async fn world_set_liquid(
1174 &self,
1175 world: impl Into<Option<types::WorldRef>>,
1176 position: impl Into<Option<types::BlockPos>>,
1177 liquid: impl Into<Option<types::LiquidState>>,
1178 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1179 self.send_action(types::action::Kind::WorldSetLiquid(
1180 types::WorldSetLiquidAction {
1181 world: world.into(),
1182 position: position.into(),
1183 liquid: liquid.into(),
1184 },
1185 ))
1186 .await
1187 }
1188 pub async fn world_schedule_block_update(
1190 &self,
1191 world: impl Into<Option<types::WorldRef>>,
1192 position: impl Into<Option<types::BlockPos>>,
1193 block: impl Into<Option<types::BlockState>>,
1194 delay_ms: i64,
1195 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1196 self.send_action(types::action::Kind::WorldScheduleBlockUpdate(
1197 types::WorldScheduleBlockUpdateAction {
1198 world: world.into(),
1199 position: position.into(),
1200 block: block.into(),
1201 delay_ms,
1202 },
1203 ))
1204 .await
1205 }
1206 pub async fn world_build_structure(
1208 &self,
1209 world: impl Into<Option<types::WorldRef>>,
1210 origin: impl Into<Option<types::BlockPos>>,
1211 structure: impl Into<Option<types::StructureDef>>,
1212 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1213 self.send_action(types::action::Kind::WorldBuildStructure(
1214 types::WorldBuildStructureAction {
1215 world: world.into(),
1216 origin: origin.into(),
1217 structure: structure.into(),
1218 },
1219 ))
1220 .await
1221 }
1222 pub async fn world_query_entities(
1224 &self,
1225 world: impl Into<Option<types::WorldRef>>,
1226 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1227 self.send_action(types::action::Kind::WorldQueryEntities(
1228 types::WorldQueryEntitiesAction {
1229 world: world.into(),
1230 },
1231 ))
1232 .await
1233 }
1234 pub async fn world_query_players(
1236 &self,
1237 world: impl Into<Option<types::WorldRef>>,
1238 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1239 self.send_action(types::action::Kind::WorldQueryPlayers(
1240 types::WorldQueryPlayersAction {
1241 world: world.into(),
1242 },
1243 ))
1244 .await
1245 }
1246 pub async fn world_query_entities_within(
1248 &self,
1249 world: impl Into<Option<types::WorldRef>>,
1250 r#box: impl Into<Option<types::BBox>>,
1251 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1252 self.send_action(types::action::Kind::WorldQueryEntitiesWithin(
1253 types::WorldQueryEntitiesWithinAction {
1254 world: world.into(),
1255 r#box: r#box.into(),
1256 },
1257 ))
1258 .await
1259 }
1260 pub async fn world_query_player_spawn(
1262 &self,
1263 world: impl Into<Option<types::WorldRef>>,
1264 player_uuid: String,
1265 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1266 self.send_action(types::action::Kind::WorldQueryPlayerSpawn(
1267 types::WorldQueryPlayerSpawnAction {
1268 world: world.into(),
1269 player_uuid,
1270 },
1271 ))
1272 .await
1273 }
1274 pub async fn world_query_block(
1276 &self,
1277 world: impl Into<Option<types::WorldRef>>,
1278 position: impl Into<Option<types::BlockPos>>,
1279 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1280 self.send_action(types::action::Kind::WorldQueryBlock(
1281 types::WorldQueryBlockAction {
1282 world: world.into(),
1283 position: position.into(),
1284 },
1285 ))
1286 .await
1287 }
1288 pub async fn world_query_biome(
1290 &self,
1291 world: impl Into<Option<types::WorldRef>>,
1292 position: impl Into<Option<types::BlockPos>>,
1293 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1294 self.send_action(types::action::Kind::WorldQueryBiome(
1295 types::WorldQueryBiomeAction {
1296 world: world.into(),
1297 position: position.into(),
1298 },
1299 ))
1300 .await
1301 }
1302 pub async fn world_query_light(
1304 &self,
1305 world: impl Into<Option<types::WorldRef>>,
1306 position: impl Into<Option<types::BlockPos>>,
1307 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1308 self.send_action(types::action::Kind::WorldQueryLight(
1309 types::WorldQueryLightAction {
1310 world: world.into(),
1311 position: position.into(),
1312 },
1313 ))
1314 .await
1315 }
1316 pub async fn world_query_sky_light(
1318 &self,
1319 world: impl Into<Option<types::WorldRef>>,
1320 position: impl Into<Option<types::BlockPos>>,
1321 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1322 self.send_action(types::action::Kind::WorldQuerySkyLight(
1323 types::WorldQuerySkyLightAction {
1324 world: world.into(),
1325 position: position.into(),
1326 },
1327 ))
1328 .await
1329 }
1330 pub async fn world_query_temperature(
1332 &self,
1333 world: impl Into<Option<types::WorldRef>>,
1334 position: impl Into<Option<types::BlockPos>>,
1335 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1336 self.send_action(types::action::Kind::WorldQueryTemperature(
1337 types::WorldQueryTemperatureAction {
1338 world: world.into(),
1339 position: position.into(),
1340 },
1341 ))
1342 .await
1343 }
1344 pub async fn world_query_highest_block(
1346 &self,
1347 world: impl Into<Option<types::WorldRef>>,
1348 x: i32,
1349 z: i32,
1350 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1351 self.send_action(types::action::Kind::WorldQueryHighestBlock(
1352 types::WorldQueryHighestBlockAction {
1353 world: world.into(),
1354 x,
1355 z,
1356 },
1357 ))
1358 .await
1359 }
1360 pub async fn world_query_raining_at(
1362 &self,
1363 world: impl Into<Option<types::WorldRef>>,
1364 position: impl Into<Option<types::BlockPos>>,
1365 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1366 self.send_action(types::action::Kind::WorldQueryRainingAt(
1367 types::WorldQueryRainingAtAction {
1368 world: world.into(),
1369 position: position.into(),
1370 },
1371 ))
1372 .await
1373 }
1374 pub async fn world_query_snowing_at(
1376 &self,
1377 world: impl Into<Option<types::WorldRef>>,
1378 position: impl Into<Option<types::BlockPos>>,
1379 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1380 self.send_action(types::action::Kind::WorldQuerySnowingAt(
1381 types::WorldQuerySnowingAtAction {
1382 world: world.into(),
1383 position: position.into(),
1384 },
1385 ))
1386 .await
1387 }
1388 pub async fn world_query_thundering_at(
1390 &self,
1391 world: impl Into<Option<types::WorldRef>>,
1392 position: impl Into<Option<types::BlockPos>>,
1393 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1394 self.send_action(types::action::Kind::WorldQueryThunderingAt(
1395 types::WorldQueryThunderingAtAction {
1396 world: world.into(),
1397 position: position.into(),
1398 },
1399 ))
1400 .await
1401 }
1402 pub async fn world_query_liquid(
1404 &self,
1405 world: impl Into<Option<types::WorldRef>>,
1406 position: impl Into<Option<types::BlockPos>>,
1407 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1408 self.send_action(types::action::Kind::WorldQueryLiquid(
1409 types::WorldQueryLiquidAction {
1410 world: world.into(),
1411 position: position.into(),
1412 },
1413 ))
1414 .await
1415 }
1416 pub async fn world_query_default_game_mode(
1418 &self,
1419 world: impl Into<Option<types::WorldRef>>,
1420 ) -> Result<(), mpsc::error::SendError<types::PluginToHost>> {
1421 self.send_action(types::action::Kind::WorldQueryDefaultGameMode(
1422 types::WorldQueryDefaultGameModeAction {
1423 world: world.into(),
1424 },
1425 ))
1426 .await
1427 }
1428}