minecraft_command_types/command/
mod.rs

1pub mod advancement;
2pub mod attribute;
3pub mod bossbar;
4pub mod clone;
5pub mod damage;
6pub mod data;
7pub mod datapack;
8pub mod debug;
9pub mod dialog;
10pub mod effect;
11pub mod enums;
12pub mod execute;
13pub mod experience;
14pub mod fetch_profile;
15pub mod fill;
16pub mod forceload;
17pub mod function;
18pub mod gamerule;
19pub mod item;
20pub mod item_source;
21pub mod locate;
22pub mod loot;
23pub mod particle;
24pub mod permission_level;
25pub mod place;
26pub mod random;
27pub mod recipe;
28pub mod r#return;
29pub mod ride;
30pub mod rotate;
31pub mod schedule;
32pub mod scoreboard;
33pub mod stopwatch;
34pub mod tag;
35pub mod team;
36pub mod teleport;
37pub mod test;
38pub mod tick;
39pub mod time;
40pub mod title;
41pub mod trigger;
42pub mod waypoint;
43pub mod whitelist;
44pub mod worldborder;
45
46use crate::block::BlockState;
47use crate::column_position::ColumnPosition;
48use crate::command::advancement::AdvancementCommand;
49use crate::command::attribute::AttributeCommand;
50use crate::command::bossbar::BossbarCommand;
51use crate::command::clone::CloneMaskMode;
52use crate::command::damage::DamageType;
53use crate::command::data::DataCommand;
54use crate::command::datapack::DatapackCommand;
55use crate::command::debug::DebugCommandType;
56use crate::command::dialog::DialogCommand;
57use crate::command::effect::EffectCommand;
58use crate::command::enums::setblock_mode::SetblockMode;
59use crate::command::enums::sound_source::{SoundSource, StopSoundSource};
60use crate::command::enums::weather_type::WeatherType;
61use crate::command::execute::ExecuteSubcommand;
62use crate::command::experience::ExperienceCommand;
63use crate::command::fetch_profile::FetchProfileCommand;
64use crate::command::fill::FillCommand;
65use crate::command::forceload::ForceloadCommand;
66use crate::command::function::FunctionCommandArguments;
67use crate::command::gamerule::GameruleValue;
68use crate::command::item::ItemCommand;
69use crate::command::item_source::ItemSource;
70use crate::command::locate::LocateType;
71use crate::command::loot::{LootSource, LootTarget};
72use crate::command::particle::ParticleCommand;
73use crate::command::permission_level::PermissionLevel;
74use crate::command::place::PlaceCommand;
75use crate::command::random::RandomCommand;
76use crate::command::recipe::RecipeType;
77use crate::command::r#return::ReturnCommand;
78use crate::command::ride::RideCommand;
79use crate::command::rotate::RotateCommand;
80use crate::command::schedule::ScheduleCommand;
81use crate::command::scoreboard::ScoreboardCommand;
82use crate::command::stopwatch::StopwatchCommand;
83use crate::command::tag::TagCommand;
84use crate::command::team::TeamCommand;
85use crate::command::teleport::TeleportCommand;
86use crate::command::test::TestCommand;
87use crate::command::tick::TickCommand;
88use crate::command::time::TimeCommand;
89use crate::command::title::TitleCommand;
90use crate::command::trigger::TriggerAction;
91use crate::command::waypoint::WaypointCommand;
92use crate::command::whitelist::WhitelistCommand;
93use crate::command::worldborder::WorldborderCommand;
94use crate::coordinate::{Coordinates, WorldCoordinate};
95use crate::entity_selector::EntitySelector;
96use crate::item::{ItemPredicate, ItemStack};
97use crate::resource_location::ResourceLocation;
98use crate::snbt::SNBT;
99use crate::time::Time;
100use enums::advancement_type::AdvancementType;
101use enums::banlist_type::BanlistType;
102use enums::clone_mode::CloneMode;
103use enums::difficulty::Difficulty;
104use enums::gamemode::Gamemode;
105use minecraft_command_types_derive::HasMacro;
106use ordered_float::NotNan;
107use std::fmt::{Display, Formatter};
108
109#[derive(Debug, Clone, Eq, PartialEq, Hash, HasMacro)]
110pub struct PlayerScore {
111    pub selector: EntitySelector,
112    pub objective: String,
113}
114
115impl Display for PlayerScore {
116    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
117        write!(f, "{} {}", self.selector, self.objective)
118    }
119}
120
121#[derive(Debug, Clone, Eq, PartialEq, Hash, HasMacro)]
122pub enum Command {
123    Advancement(AdvancementType, EntitySelector, AdvancementCommand),
124    Attribute(EntitySelector, ResourceLocation, AttributeCommand),
125    Ban(EntitySelector, Option<String>),
126    BanIP(String, Option<String>),
127    Banlist(Option<BanlistType>),
128    Bossbar(BossbarCommand),
129    Clear(Option<EntitySelector>, Option<ItemPredicate>, Option<i32>),
130    Clone {
131        source_dimension: Option<ResourceLocation>,
132        begin: Coordinates,
133        end: Coordinates,
134        target_dimension: Option<ResourceLocation>,
135        destination: Coordinates,
136        strict: bool,
137        mask_mode: CloneMaskMode,
138        clone_mode: CloneMode,
139    },
140    Damage(
141        EntitySelector,
142        NotNan<f32>,
143        Option<ResourceLocation>,
144        Option<DamageType>,
145    ),
146    Data(DataCommand),
147    Datapack(DatapackCommand),
148    Debug(DebugCommandType),
149    DefaultGamemode(Gamemode),
150    Deop(EntitySelector),
151    Dialog(DialogCommand),
152    Difficulty(Difficulty),
153    Effect(EffectCommand),
154    Enchant(EntitySelector, ResourceLocation, Option<i32>),
155    Execute(ExecuteSubcommand),
156    Experience(ExperienceCommand),
157    FetchProfile(FetchProfileCommand),
158    Fill(Coordinates, Coordinates, BlockState, Option<FillCommand>),
159    FillBiome(
160        Coordinates,
161        Coordinates,
162        ResourceLocation,
163        Option<ResourceLocation>,
164    ),
165    Forceload(ForceloadCommand),
166    Function(ResourceLocation, Option<FunctionCommandArguments>),
167    Gamemode(Gamemode, Option<EntitySelector>),
168    Gamerule(String, Option<GameruleValue>),
169    Give(EntitySelector, ItemStack, Option<i32>),
170    Help(Option<String>),
171    Item(ItemSource, String, ItemCommand),
172    JFR(bool),
173    Kick(EntitySelector, Option<String>),
174    Kill(Option<EntitySelector>),
175    List(bool),
176    Locate(LocateType, ResourceLocation),
177    Loot(LootTarget, LootSource),
178    Me(String),
179    Message(EntitySelector, String),
180    Op(EntitySelector),
181    Pardon(EntitySelector),
182    PardonIp(String),
183    Particle(ParticleCommand),
184    Perf(bool),
185    Place(PlaceCommand),
186    Playsound(
187        ResourceLocation,
188        Option<SoundSource>,
189        Option<EntitySelector>,
190        Option<WorldCoordinate>,
191        Option<NotNan<f32>>,
192        Option<NotNan<f32>>,
193        Option<NotNan<f32>>,
194    ),
195    Publish(Option<bool>, Option<Gamemode>, Option<i32>),
196    Random(RandomCommand),
197    Recipe(bool, EntitySelector, RecipeType),
198    Reload,
199    Return(ReturnCommand),
200    Ride(EntitySelector, RideCommand),
201    Rotate(EntitySelector, RotateCommand),
202    SaveAll(bool),
203    SaveOff,
204    SaveOn,
205    Say(String),
206    Schedule(ScheduleCommand),
207    Scoreboard(ScoreboardCommand),
208    Seed,
209    Setblock(Coordinates, BlockState, Option<SetblockMode>),
210    SetIdleTimeout(i32),
211    SetWorldSpawn(Option<Coordinates>, Option<NotNan<f32>>),
212    Spawnpoint(
213        Option<EntitySelector>,
214        Option<Coordinates>,
215        Option<NotNan<f32>>,
216    ),
217    Spectate(Option<EntitySelector>, Option<EntitySelector>),
218    SpreadPlayers(
219        ColumnPosition,
220        NotNan<f32>,
221        NotNan<f32>,
222        Option<i32>,
223        bool,
224        EntitySelector,
225    ),
226    Stop,
227    StopSound(
228        EntitySelector,
229        Option<StopSoundSource>,
230        Option<ResourceLocation>,
231    ),
232    Stopwatch(StopwatchCommand),
233    Summon(EntitySelector, Option<Coordinates>, Option<SNBT>),
234    Tag(EntitySelector, TagCommand),
235    Team(TeamCommand),
236    TeamMessage(String),
237    Teleport(TeleportCommand),
238    Tellraw(EntitySelector, SNBT),
239    Test(TestCommand),
240    Tick(TickCommand),
241    Time(TimeCommand),
242    Title(EntitySelector, TitleCommand),
243    Transfer(String, Option<i32>, Option<EntitySelector>),
244    Trigger(String, Option<TriggerAction>),
245    Version,
246    Waypoint(WaypointCommand),
247    Weather(WeatherType, Option<Time>),
248    Whitelist(WhitelistCommand),
249    Worldborder(WorldborderCommand),
250}
251
252impl Command {
253    pub fn get_permission_level(&self, is_multiplayer: bool) -> PermissionLevel {
254        match self {
255            Command::Help(..)
256            | Command::List(..)
257            | Command::Me(..)
258            | Command::Message(..)
259            | Command::Random(RandomCommand::ValueRoll(_, _, None))
260            | Command::Random(RandomCommand::Reset(..))
261            | Command::TeamMessage(..)
262            | Command::Trigger(..) => PermissionLevel::try_from(0).unwrap(),
263            Command::Advancement(..)
264            | Command::Attribute(..)
265            | Command::Bossbar(..)
266            | Command::Clear(..)
267            | Command::Clone { .. }
268            | Command::Damage(..)
269            | Command::Data(..)
270            | Command::Datapack(..)
271            | Command::DefaultGamemode(..)
272            | Command::Dialog(..)
273            | Command::Difficulty(..)
274            | Command::Effect(..)
275            | Command::Enchant(..)
276            | Command::Execute(..)
277            | Command::Experience(..)
278            | Command::FetchProfile(..)
279            | Command::Fill(..)
280            | Command::FillBiome(..)
281            | Command::Forceload(..)
282            | Command::Function(..)
283            | Command::Gamemode(..)
284            | Command::Gamerule(..)
285            | Command::Give(..)
286            | Command::Item(..)
287            | Command::Kill(..)
288            | Command::Locate(..)
289            | Command::Loot(..)
290            | Command::Particle(..)
291            | Command::Place(..)
292            | Command::Playsound(..)
293            | Command::Random(RandomCommand::ValueRoll(_, _, Some(_)))
294            | Command::Recipe(..)
295            | Command::Reload
296            | Command::Return(..)
297            | Command::Ride(..)
298            | Command::Rotate(..)
299            | Command::Say(..)
300            | Command::Schedule(..)
301            | Command::Scoreboard(..)
302            | Command::Setblock(..)
303            | Command::SetWorldSpawn(..)
304            | Command::Spawnpoint(..)
305            | Command::Spectate(..)
306            | Command::SpreadPlayers(..)
307            | Command::StopSound(..)
308            | Command::Summon(..)
309            | Command::Tag(..)
310            | Command::Team(..)
311            | Command::Teleport(..)
312            | Command::Tellraw(..)
313            | Command::Test(..)
314            | Command::Time(..)
315            | Command::Title(..)
316            | Command::Version
317            | Command::Waypoint(..)
318            | Command::Weather(..)
319            | Command::Worldborder(..) => PermissionLevel::try_from(2).unwrap(),
320            Command::Ban(..)
321            | Command::BanIP(..)
322            | Command::Banlist(..)
323            | Command::Debug(..)
324            | Command::Deop(..)
325            | Command::Kick(..)
326            | Command::Op(..)
327            | Command::Pardon(..)
328            | Command::PardonIp(..)
329            | Command::SetIdleTimeout(..)
330            | Command::Tick(..)
331            | Command::Transfer(..)
332            | Command::Whitelist(..) => PermissionLevel::try_from(3).unwrap(),
333            Command::JFR(..)
334            | Command::Perf(..)
335            | Command::Publish(..)
336            | Command::SaveAll(..)
337            | Command::SaveOff
338            | Command::SaveOn
339            | Command::Stop
340            | Command::Stopwatch(..) => PermissionLevel::try_from(4).unwrap(),
341            Command::Seed => {
342                let level = if is_multiplayer { 2 } else { 0 };
343                PermissionLevel::try_from(level).unwrap()
344            }
345        }
346    }
347
348    pub fn is_multiplayer_only(&self) -> bool {
349        matches!(
350            self,
351            Command::Ban(..)
352                | Command::BanIP(..)
353                | Command::Banlist(..)
354                | Command::Deop(..)
355                | Command::Op(..)
356                | Command::Pardon(..)
357                | Command::PardonIp(..)
358                | Command::Perf(..)
359                | Command::SaveAll(..)
360                | Command::SaveOff
361                | Command::SaveOn
362                | Command::SetIdleTimeout(..)
363                | Command::Stop
364                | Command::Transfer(..)
365                | Command::Whitelist(..)
366        )
367    }
368}
369
370impl Display for Command {
371    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
372        match self {
373            Command::Advancement(type_, selector, command) => {
374                write!(f, "advancement {} {} {}", type_, selector, command)
375            }
376            Command::Attribute(selector, attribute, command) => {
377                write!(f, "attribute {} {} {}", selector, attribute, command)
378            }
379            Command::Ban(selectors, reason) => {
380                write!(f, "ban {}", selectors)?;
381
382                if let Some(reason) = reason {
383                    write!(f, " {}", reason)?;
384                }
385
386                Ok(())
387            }
388            Command::BanIP(target, reason) => {
389                write!(f, "ban-ip {}", target)?;
390
391                if let Some(reason) = reason {
392                    write!(f, " {}", reason)?;
393                }
394
395                Ok(())
396            }
397            Command::Banlist(type_) => {
398                f.write_str("banlist")?;
399
400                if let Some(type_) = type_ {
401                    write!(f, " {}", type_)?;
402                }
403
404                Ok(())
405            }
406            Command::Bossbar(command) => write!(f, "bossbar {}", command),
407            Command::Clear(selector, item, max_count) => {
408                f.write_str("clear")?;
409
410                if let Some(selector) = selector {
411                    write!(f, " {}", selector)?;
412
413                    if let Some(item) = item {
414                        write!(f, " {}", item)?;
415
416                        if let Some(max_count) = max_count {
417                            write!(f, " {}", max_count)?;
418                        }
419                    }
420                }
421
422                Ok(())
423            }
424            Command::Clone {
425                source_dimension,
426                begin,
427                end,
428                target_dimension,
429                destination,
430                strict,
431                mask_mode,
432                clone_mode,
433            } => {
434                f.write_str("clone")?;
435
436                if let Some(source_dimension) = source_dimension {
437                    write!(f, " from {}", source_dimension)?;
438                }
439
440                write!(f, " {} {}", begin, end)?;
441
442                if let Some(target_dimension) = target_dimension {
443                    write!(f, " to {}", target_dimension)?;
444                }
445
446                write!(f, " {}", destination)?;
447
448                if *strict {
449                    write!(f, " strict")?;
450                }
451
452                write!(f, " {} {}", mask_mode, clone_mode)
453            }
454            Command::Damage(target, amount, type_, command_type) => {
455                write!(f, "damage {} {}", target, amount)?;
456
457                if let Some(type_) = type_ {
458                    write!(f, " {}", type_)?;
459
460                    if let Some(command_type) = command_type {
461                        write!(f, " {}", command_type)?;
462                    }
463                }
464
465                Ok(())
466            }
467            Command::Data(data_command) => write!(f, "data {}", data_command),
468            Command::Datapack(datapack_command) => write!(f, "datapack {},", datapack_command),
469            Command::Debug(debug_type) => write!(f, "debug {}", debug_type),
470            Command::DefaultGamemode(gamemode) => write!(f, "defaultgamemode {}", gamemode),
471            Command::Deop(selector) => write!(f, "deop {}", selector),
472            Command::Dialog(dialog_command) => write!(f, "dialog {}", dialog_command),
473            Command::Difficulty(difficulty) => write!(f, "difficulty {}", difficulty),
474            Command::Effect(effect_command) => write!(f, "effect {}", effect_command),
475            Command::Enchant(selector, enchantment, level) => {
476                write!(f, "enchant {} {}", selector, enchantment)?;
477
478                if let Some(level) = level {
479                    write!(f, " {}", level)?;
480                }
481
482                Ok(())
483            }
484            Command::Execute(subcommand) => write!(f, "execute {}", subcommand),
485            Command::Experience(command) => write!(f, "experience {}", command),
486            Command::FetchProfile(command) => write!(f, "fetchprofile {}", command),
487            Command::Fill(from, to, block_state, command) => {
488                write!(f, "fill {} {} {}", from, to, block_state)?;
489
490                if let Some(command) = command {
491                    write!(f, " {}", command)?;
492                }
493
494                Ok(())
495            }
496            Command::FillBiome(from, to, biome, filter) => {
497                write!(f, "fillbiome {} {} {}", from, to, biome)?;
498
499                if let Some(filter) = filter {
500                    write!(f, " {}", filter)?;
501                }
502
503                Ok(())
504            }
505            Command::Forceload(command) => write!(f, "forceload {}", command),
506            Command::Function(function, arguments) => {
507                write!(f, "function {}", function)?;
508
509                if let Some(arguments) = arguments {
510                    write!(f, " {}", arguments)?;
511                }
512
513                Ok(())
514            }
515            Command::Gamemode(gamemode, selector) => {
516                write!(f, "gamemode {}", gamemode)?;
517
518                if let Some(selector) = selector {
519                    write!(f, " {}", selector)?;
520                }
521
522                Ok(())
523            }
524            Command::Gamerule(name, value) => {
525                write!(f, "gamerule {}", name)?;
526
527                if let Some(value) = value {
528                    write!(f, " {}", value)?;
529                }
530
531                Ok(())
532            }
533            Command::Give(selector, item, count) => {
534                write!(f, "give {} {}", selector, item)?;
535
536                if let Some(count) = count {
537                    write!(f, " {}", count)?;
538                }
539
540                Ok(())
541            }
542            Command::Help(command) => {
543                f.write_str("help")?;
544
545                if let Some(command) = command {
546                    write!(f, " {}", command)?;
547                }
548
549                Ok(())
550            }
551            Command::Item(source, slot, command) => {
552                write!(f, "item {} {} {}", source, slot, command)
553            }
554            Command::JFR(start) => {
555                f.write_str("jfr ")?;
556
557                if *start {
558                    f.write_str("start")
559                } else {
560                    f.write_str("stop")
561                }
562            }
563            Command::Kick(selector, reason) => {
564                write!(f, "kick {}", selector)?;
565
566                if let Some(reason) = reason {
567                    write!(f, " {}", reason)?;
568                }
569
570                Ok(())
571            }
572            Command::Kill(selector) => {
573                f.write_str("kill")?;
574
575                if let Some(selector) = selector {
576                    write!(f, " {}", selector)?;
577                }
578
579                Ok(())
580            }
581            Command::List(show_uuids) => {
582                f.write_str("list")?;
583
584                if *show_uuids {
585                    f.write_str(" uuids")?;
586                }
587
588                Ok(())
589            }
590            Command::Locate(locate_type, id) => {
591                write!(f, "locate {} {}", locate_type, id)
592            }
593            Command::Loot(target, source) => {
594                write!(f, "loot {} {}", target, source)
595            }
596            Command::Me(message) => {
597                write!(f, "me {}", message)
598            }
599            Command::Message(selector, message) => {
600                write!(f, "msg {} {}", selector, message)
601            }
602            Command::Op(selector) => {
603                write!(f, "op {}", selector)
604            }
605            Command::Pardon(selector) => {
606                write!(f, "pardon {}", selector)
607            }
608            Command::PardonIp(selector) => {
609                write!(f, "pardon-ip {}", selector)
610            }
611            Command::Particle(command) => {
612                write!(f, "particle {}", command)
613            }
614            Command::Perf(start) => {
615                f.write_str("perf ")?;
616
617                if *start {
618                    f.write_str("start")
619                } else {
620                    f.write_str("stop")
621                }
622            }
623            Command::Place(command) => {
624                write!(f, "place {}", command)
625            }
626            Command::Playsound(sound, source, selector, pos, volume, pitch, minimum_volume) => {
627                write!(f, "playsound {}", sound)?;
628
629                if let Some(source) = source {
630                    write!(f, " {}", source)?;
631
632                    if let Some(selector) = selector {
633                        write!(f, " {}", selector)?;
634
635                        if let Some(pos) = pos {
636                            write!(f, " {}", pos)?;
637
638                            if let Some(volume) = volume {
639                                write!(f, " {}", volume)?;
640
641                                if let Some(pitch) = pitch {
642                                    write!(f, " {}", pitch)?;
643
644                                    if let Some(minimum_volume) = minimum_volume {
645                                        write!(f, " {}", minimum_volume)?;
646                                    }
647                                }
648                            }
649                        }
650                    }
651                }
652
653                Ok(())
654            }
655            Command::Publish(allow_commands, gamemode, port) => {
656                f.write_str("playsound")?;
657
658                if let Some(allow_commands) = allow_commands {
659                    write!(f, " {}", allow_commands)?;
660
661                    if let Some(gamemode) = gamemode {
662                        write!(f, " {}", gamemode)?;
663
664                        if let Some(port) = port {
665                            write!(f, " {}", port)?;
666                        }
667                    }
668                }
669
670                Ok(())
671            }
672            Command::Random(command) => {
673                write!(f, "random {}", command)
674            }
675            Command::Recipe(give, selector, recipe_type) => {
676                f.write_str("recipe ")?;
677
678                if *give {
679                    f.write_str("give")?;
680                } else {
681                    f.write_str("take")?;
682                }
683
684                write!(f, " {} {}", selector, recipe_type)
685            }
686            Command::Reload => f.write_str("reload"),
687            Command::Return(command) => {
688                write!(f, "return {}", command)
689            }
690            Command::Ride(selector, command) => {
691                write!(f, "ride {} {}", selector, command)
692            }
693            Command::Rotate(selector, command) => {
694                write!(f, "rotate {} {}", selector, command)
695            }
696            Command::SaveAll(should_flush) => {
697                f.write_str("save-all")?;
698
699                if *should_flush {
700                    f.write_str(" flush")?;
701                }
702
703                Ok(())
704            }
705            Command::SaveOff => f.write_str("save-off"),
706            Command::SaveOn => f.write_str("save-on"),
707            Command::Say(message) => {
708                write!(f, "say {}", message)
709            }
710            Command::Schedule(command) => {
711                write!(f, "schedule {}", command)
712            }
713            Command::Scoreboard(command) => {
714                write!(f, "scoreboard {}", command)
715            }
716            Command::Seed => f.write_str("seed"),
717            Command::Setblock(coordinates, block, mode) => {
718                write!(f, "setblock {} {}", coordinates, block)?;
719
720                if let Some(mode) = mode {
721                    write!(f, " {}", mode)?;
722                }
723
724                Ok(())
725            }
726            Command::SetIdleTimeout(minutes) => {
727                write!(f, "setidletimeout {}", minutes)
728            }
729            Command::SetWorldSpawn(coordinates, angle) => {
730                f.write_str("setworldspawn")?;
731
732                if let Some(coordinates) = coordinates {
733                    write!(f, " {}", coordinates)?;
734
735                    if let Some(angle) = angle {
736                        write!(f, " {}", angle)?;
737                    }
738                }
739
740                Ok(())
741            }
742            Command::Spawnpoint(selector, coordinates, angle) => {
743                f.write_str("spawnpoint")?;
744
745                if let Some(selector) = selector {
746                    write!(f, " {}", selector)?;
747                    if let Some(coordinates) = coordinates {
748                        write!(f, " {}", coordinates)?;
749
750                        if let Some(angle) = angle {
751                            write!(f, " {}", angle)?;
752                        }
753                    }
754                }
755
756                Ok(())
757            }
758            Command::Spectate(selector1, selector2) => {
759                f.write_str("spectate")?;
760
761                if let Some(selector1) = selector1 {
762                    write!(f, " {}", selector1)?;
763
764                    if let Some(selector2) = selector2 {
765                        write!(f, " {}", selector2)?;
766                    }
767                }
768
769                Ok(())
770            }
771            Command::SpreadPlayers(
772                center,
773                spread_distance,
774                max_range,
775                max_height,
776                respect_teams,
777                targets,
778            ) => {
779                write!(
780                    f,
781                    "spreadplayers {} {} {} ",
782                    center, spread_distance, max_range
783                )?;
784
785                if let Some(max_height) = max_height {
786                    write!(f, "under {} ", max_height)?;
787                }
788
789                write!(f, "{} {}", respect_teams, targets)
790            }
791            Command::Stop => f.write_str("stop"),
792            Command::StopSound(selector, source, sound) => {
793                write!(f, "stopsound {}", selector)?;
794
795                if let Some(source) = source {
796                    write!(f, " {}", source)?;
797
798                    if let Some(sound) = sound {
799                        write!(f, " {}", sound)?;
800                    }
801                }
802
803                Ok(())
804            }
805            Command::Stopwatch(command) => {
806                write!(f, "stopwatch {}", command)
807            }
808            Command::Summon(location, coordinates, snbt) => {
809                write!(f, "summon {}", location)?;
810
811                if let Some(coordinates) = coordinates {
812                    write!(f, " {}", coordinates)?;
813
814                    if let Some(snbt) = snbt {
815                        write!(f, " {}", snbt)?;
816                    }
817                }
818
819                Ok(())
820            }
821            Command::Tag(selector, command) => {
822                write!(f, "tag {} {}", selector, command)
823            }
824            Command::Team(command) => {
825                write!(f, "team {}", command)
826            }
827            Command::TeamMessage(message) => {
828                write!(f, "teammsg {}", message)
829            }
830            Command::Teleport(command) => {
831                write!(f, "teleport {}", command)
832            }
833            Command::Tellraw(selector, message) => {
834                write!(f, "tellraw {} {}", selector, message)
835            }
836            Command::Test(command) => {
837                write!(f, "test {}", command)
838            }
839            Command::Tick(command) => write!(f, "tick {}", command),
840            Command::Time(command) => write!(f, "time {}", command),
841            Command::Title(selector, command) => write!(f, "title {} {}", selector, command),
842            Command::Transfer(hostname, port, selector) => {
843                write!(f, "transfer {}", hostname)?;
844
845                if let Some(port) = port {
846                    write!(f, " {}", port)?;
847
848                    if let Some(selector) = selector {
849                        write!(f, " {}", selector)?;
850                    }
851                }
852
853                Ok(())
854            }
855            Command::Trigger(objective, action) => {
856                write!(f, "trigger {}", objective)?;
857
858                if let Some(action) = action {
859                    write!(f, " {}", action)?;
860                }
861
862                Ok(())
863            }
864            Command::Version => f.write_str("version"),
865            Command::Waypoint(command) => write!(f, "waypoint {}", command),
866            Command::Weather(type_, duration) => {
867                write!(f, "weather {}", type_)?;
868
869                if let Some(duration) = duration {
870                    write!(f, " {}", duration)?;
871                }
872
873                Ok(())
874            }
875            Command::Whitelist(command) => write!(f, "whitelist {}", command),
876            Command::Worldborder(command) => write!(f, "worldborder {}", command),
877        }
878    }
879}