From d4b1a5f1b7c5b5536ac45c2415277b1836874f87 Mon Sep 17 00:00:00 2001 From: Smuu <18609909+Smuu@users.noreply.github.com> Date: Sun, 29 Dec 2024 14:58:25 +0100 Subject: [PATCH] fix: formatting Signed-off-by: Smuu <18609909+Smuu@users.noreply.github.com> --- pumpkin/src/command/commands/cmd_fill.rs | 25 +++++++++--------- pumpkin/src/command/commands/cmd_gamemode.rs | 15 +++++------ pumpkin/src/command/commands/cmd_give.rs | 15 +++++------ pumpkin/src/command/commands/cmd_seed.rs | 3 +-- pumpkin/src/command/commands/cmd_setblock.rs | 19 +++++++------- pumpkin/src/command/commands/cmd_stop.rs | 1 - pumpkin/src/command/commands/cmd_teleport.rs | 4 +-- pumpkin/src/command/commands/cmd_time.rs | 19 ++++++++------ pumpkin/src/command/commands/cmd_transfer.rs | 27 +++++++++----------- pumpkin/src/command/dispatcher.rs | 7 ++--- pumpkin/src/command/tree_builder.rs | 4 +-- 11 files changed, 66 insertions(+), 73 deletions(-) diff --git a/pumpkin/src/command/commands/cmd_fill.rs b/pumpkin/src/command/commands/cmd_fill.rs index 829bd900..c4e7476f 100644 --- a/pumpkin/src/command/commands/cmd_fill.rs +++ b/pumpkin/src/command/commands/cmd_fill.rs @@ -155,18 +155,17 @@ impl CommandExecutor for SetblockExecutor { } pub fn init_command_tree() -> CommandTree { - CommandTree::new(NAMES, DESCRIPTION) - .with_child( - argument(ARG_FROM, BlockPosArgumentConsumer).with_child( - argument(ARG_TO, BlockPosArgumentConsumer).with_child( - argument(ARG_BLOCK, BlockArgumentConsumer) - .with_child(literal("destroy").execute(SetblockExecutor(Mode::Destroy))) - .with_child(literal("hollow").execute(SetblockExecutor(Mode::Hollow))) - .with_child(literal("keep").execute(SetblockExecutor(Mode::Keep))) - .with_child(literal("outline").execute(SetblockExecutor(Mode::Outline))) - .with_child(literal("replace").execute(SetblockExecutor(Mode::Replace))) - .execute(SetblockExecutor(Mode::Replace)), - ), + CommandTree::new(NAMES, DESCRIPTION).with_child( + argument(ARG_FROM, BlockPosArgumentConsumer).with_child( + argument(ARG_TO, BlockPosArgumentConsumer).with_child( + argument(ARG_BLOCK, BlockArgumentConsumer) + .with_child(literal("destroy").execute(SetblockExecutor(Mode::Destroy))) + .with_child(literal("hollow").execute(SetblockExecutor(Mode::Hollow))) + .with_child(literal("keep").execute(SetblockExecutor(Mode::Keep))) + .with_child(literal("outline").execute(SetblockExecutor(Mode::Outline))) + .with_child(literal("replace").execute(SetblockExecutor(Mode::Replace))) + .execute(SetblockExecutor(Mode::Replace)), ), - ) + ), + ) } diff --git a/pumpkin/src/command/commands/cmd_gamemode.rs b/pumpkin/src/command/commands/cmd_gamemode.rs index d61ce272..14f16911 100644 --- a/pumpkin/src/command/commands/cmd_gamemode.rs +++ b/pumpkin/src/command/commands/cmd_gamemode.rs @@ -107,12 +107,11 @@ impl CommandExecutor for GamemodeTargetPlayer { #[allow(clippy::redundant_closure_for_method_calls)] pub fn init_command_tree() -> CommandTree { - CommandTree::new(NAMES, DESCRIPTION) - .with_child( - argument(ARG_GAMEMODE, GamemodeArgumentConsumer) - .with_child(require(|sender| sender.is_player()).execute(GamemodeTargetSelf)) - .with_child( - argument(ARG_TARGET, PlayersArgumentConsumer).execute(GamemodeTargetPlayer), - ), - ) + CommandTree::new(NAMES, DESCRIPTION).with_child( + argument(ARG_GAMEMODE, GamemodeArgumentConsumer) + .with_child(require(|sender| sender.is_player()).execute(GamemodeTargetSelf)) + .with_child( + argument(ARG_TARGET, PlayersArgumentConsumer).execute(GamemodeTargetPlayer), + ), + ) } diff --git a/pumpkin/src/command/commands/cmd_give.rs b/pumpkin/src/command/commands/cmd_give.rs index c1347805..6b9b3f07 100644 --- a/pumpkin/src/command/commands/cmd_give.rs +++ b/pumpkin/src/command/commands/cmd_give.rs @@ -74,12 +74,11 @@ impl CommandExecutor for GiveExecutor { } pub fn init_command_tree() -> CommandTree { - CommandTree::new(NAMES, DESCRIPTION) - .with_child( - argument_default_name(PlayersArgumentConsumer).with_child( - argument(ARG_ITEM, ItemArgumentConsumer) - .execute(GiveExecutor) - .with_child(argument_default_name(item_count_consumer()).execute(GiveExecutor)), - ), - ) + CommandTree::new(NAMES, DESCRIPTION).with_child( + argument_default_name(PlayersArgumentConsumer).with_child( + argument(ARG_ITEM, ItemArgumentConsumer) + .execute(GiveExecutor) + .with_child(argument_default_name(item_count_consumer()).execute(GiveExecutor)), + ), + ) } diff --git a/pumpkin/src/command/commands/cmd_seed.rs b/pumpkin/src/command/commands/cmd_seed.rs index e4c031e0..a3094193 100644 --- a/pumpkin/src/command/commands/cmd_seed.rs +++ b/pumpkin/src/command/commands/cmd_seed.rs @@ -53,6 +53,5 @@ impl CommandExecutor for PumpkinExecutor { } pub fn init_command_tree() -> CommandTree { - CommandTree::new(NAMES, DESCRIPTION) - .execute(PumpkinExecutor) + CommandTree::new(NAMES, DESCRIPTION).execute(PumpkinExecutor) } diff --git a/pumpkin/src/command/commands/cmd_setblock.rs b/pumpkin/src/command/commands/cmd_setblock.rs index ef06760f..ee8310d0 100644 --- a/pumpkin/src/command/commands/cmd_setblock.rs +++ b/pumpkin/src/command/commands/cmd_setblock.rs @@ -79,14 +79,13 @@ impl CommandExecutor for SetblockExecutor { } pub fn init_command_tree() -> CommandTree { - CommandTree::new(NAMES, DESCRIPTION) - .with_child( - argument(ARG_BLOCK_POS, BlockPosArgumentConsumer).with_child( - argument(ARG_BLOCK, BlockArgumentConsumer) - .with_child(literal("replace").execute(SetblockExecutor(Mode::Replace))) - .with_child(literal("destroy").execute(SetblockExecutor(Mode::Destroy))) - .with_child(literal("keep").execute(SetblockExecutor(Mode::Keep))) - .execute(SetblockExecutor(Mode::Replace)), - ), - ) + CommandTree::new(NAMES, DESCRIPTION).with_child( + argument(ARG_BLOCK_POS, BlockPosArgumentConsumer).with_child( + argument(ARG_BLOCK, BlockArgumentConsumer) + .with_child(literal("replace").execute(SetblockExecutor(Mode::Replace))) + .with_child(literal("destroy").execute(SetblockExecutor(Mode::Destroy))) + .with_child(literal("keep").execute(SetblockExecutor(Mode::Keep))) + .execute(SetblockExecutor(Mode::Replace)), + ), + ) } diff --git a/pumpkin/src/command/commands/cmd_stop.rs b/pumpkin/src/command/commands/cmd_stop.rs index 078697db..c1f3f4f3 100644 --- a/pumpkin/src/command/commands/cmd_stop.rs +++ b/pumpkin/src/command/commands/cmd_stop.rs @@ -38,4 +38,3 @@ impl CommandExecutor for StopExecutor { pub fn init_command_tree() -> CommandTree { CommandTree::new(NAMES, DESCRIPTION).execute(StopExecutor) } - diff --git a/pumpkin/src/command/commands/cmd_teleport.rs b/pumpkin/src/command/commands/cmd_teleport.rs index 914e1db2..d5f535f1 100644 --- a/pumpkin/src/command/commands/cmd_teleport.rs +++ b/pumpkin/src/command/commands/cmd_teleport.rs @@ -238,9 +238,7 @@ impl CommandExecutor for TpSelfToPosExecutor { pub fn init_command_tree() -> CommandTree { CommandTree::new(NAMES, DESCRIPTION) - .with_child( - argument(ARG_LOCATION, Position3DArgumentConsumer).execute(TpSelfToPosExecutor), - ) + .with_child(argument(ARG_LOCATION, Position3DArgumentConsumer).execute(TpSelfToPosExecutor)) .with_child( argument(ARG_DESTINATION, EntityArgumentConsumer).execute(TpSelfToEntityExecutor), ) diff --git a/pumpkin/src/command/commands/cmd_time.rs b/pumpkin/src/command/commands/cmd_time.rs index a6358d4c..c28f712a 100644 --- a/pumpkin/src/command/commands/cmd_time.rs +++ b/pumpkin/src/command/commands/cmd_time.rs @@ -6,8 +6,7 @@ use crate::command::args::arg_bounded_num::BoundedNumArgumentConsumer; use crate::command::args::FindArgDefaultName; use crate::command::tree_builder::{argument_default_name, literal}; use crate::command::{ - tree::CommandTree, CommandError, CommandExecutor, CommandSender, - ConsumedArgs, + tree::CommandTree, CommandError, CommandExecutor, CommandSender, ConsumedArgs, }; const NAMES: [&str; 1] = ["time"]; @@ -125,16 +124,20 @@ impl CommandExecutor for TimeChangeExecutor { pub fn init_command_tree() -> CommandTree { CommandTree::new(NAMES, DESCRIPTION) - .with_child(literal("add").with_child( - argument_default_name(arg_number()).execute(TimeChangeExecutor(Mode::Add)), - )) + .with_child( + literal("add").with_child( + argument_default_name(arg_number()).execute(TimeChangeExecutor(Mode::Add)), + ), + ) .with_child( literal("query") .with_child(literal("daytime").execute(TimeQueryExecutor(QueryMode::DayTime))) .with_child(literal("gametime").execute(TimeQueryExecutor(QueryMode::GameTime))) .with_child(literal("day").execute(TimeQueryExecutor(QueryMode::Day))), ) - .with_child(literal("set").with_child( - argument_default_name(arg_number()).execute(TimeChangeExecutor(Mode::Set)), - )) + .with_child( + literal("set").with_child( + argument_default_name(arg_number()).execute(TimeChangeExecutor(Mode::Set)), + ), + ) } diff --git a/pumpkin/src/command/commands/cmd_transfer.rs b/pumpkin/src/command/commands/cmd_transfer.rs index bfe75f69..50473920 100644 --- a/pumpkin/src/command/commands/cmd_transfer.rs +++ b/pumpkin/src/command/commands/cmd_transfer.rs @@ -119,19 +119,16 @@ impl CommandExecutor for TransferTargetPlayer { #[allow(clippy::redundant_closure_for_method_calls)] pub fn init_command_tree() -> CommandTree { - CommandTree::new(NAMES, DESCRIPTION) - .with_child( - argument(ARG_HOSTNAME, SimpleArgConsumer) - .with_child(require(|sender| sender.is_player()).execute(TransferTargetSelf)) - .with_child( - argument_default_name(port_consumer()) - .with_child( - require(|sender| sender.is_player()).execute(TransferTargetSelf), - ) - .with_child( - argument(ARG_PLAYERS, PlayersArgumentConsumer) - .execute(TransferTargetPlayer), - ), - ), - ) + CommandTree::new(NAMES, DESCRIPTION).with_child( + argument(ARG_HOSTNAME, SimpleArgConsumer) + .with_child(require(|sender| sender.is_player()).execute(TransferTargetSelf)) + .with_child( + argument_default_name(port_consumer()) + .with_child(require(|sender| sender.is_player()).execute(TransferTargetSelf)) + .with_child( + argument(ARG_PLAYERS, PlayersArgumentConsumer) + .execute(TransferTargetPlayer), + ), + ), + ) } diff --git a/pumpkin/src/command/dispatcher.rs b/pumpkin/src/command/dispatcher.rs index e46b34fa..b59b0680 100644 --- a/pumpkin/src/command/dispatcher.rs +++ b/pumpkin/src/command/dispatcher.rs @@ -1,11 +1,11 @@ -use pumpkin_core::text::TextComponent; use pumpkin_core::permission::PermissionLvl; +use pumpkin_core::text::TextComponent; use pumpkin_protocol::client::play::CommandSuggestion; use super::args::ConsumedArgs; use crate::command::dispatcher::CommandError::{ - GeneralCommandIssue, InvalidConsumption, InvalidRequirement, PermissionDenied, OtherPumpkin, + GeneralCommandIssue, InvalidConsumption, InvalidRequirement, OtherPumpkin, PermissionDenied, }; use crate::command::tree::{Command, CommandTree, NodeType, RawArgs}; use crate::command::CommandSender; @@ -304,7 +304,8 @@ impl CommandDispatcher { .insert(name.to_string(), Command::Alias(primary_name.to_string())); } - self.permissions.insert(primary_name.to_string(), permission); + self.permissions + .insert(primary_name.to_string(), permission); self.commands .insert(primary_name.to_string(), Command::Tree(tree)); } diff --git a/pumpkin/src/command/tree_builder.rs b/pumpkin/src/command/tree_builder.rs index c98b0e61..f9d5bff9 100644 --- a/pumpkin/src/command/tree_builder.rs +++ b/pumpkin/src/command/tree_builder.rs @@ -1,10 +1,10 @@ use std::sync::Arc; +use super::args::DefaultNameArgConsumer; +use super::CommandExecutor; use crate::command::args::ArgumentConsumer; use crate::command::tree::{CommandTree, Node, NodeType}; use crate::command::CommandSender; -use super::args::DefaultNameArgConsumer; -use super::CommandExecutor; impl CommandTree { /// Add a child [Node] to the root of this [`CommandTree`].