Skip to content

Commit

Permalink
fix: formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Smuu <[email protected]>
  • Loading branch information
smuu committed Dec 29, 2024
1 parent b972b94 commit d4b1a5f
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 73 deletions.
25 changes: 12 additions & 13 deletions pumpkin/src/command/commands/cmd_fill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
),
)
),
)
}
15 changes: 7 additions & 8 deletions pumpkin/src/command/commands/cmd_gamemode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
)
}
15 changes: 7 additions & 8 deletions pumpkin/src/command/commands/cmd_give.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
),
)
}
3 changes: 1 addition & 2 deletions pumpkin/src/command/commands/cmd_seed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
19 changes: 9 additions & 10 deletions pumpkin/src/command/commands/cmd_setblock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
),
)
}
1 change: 0 additions & 1 deletion pumpkin/src/command/commands/cmd_stop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,3 @@ impl CommandExecutor for StopExecutor {
pub fn init_command_tree() -> CommandTree {
CommandTree::new(NAMES, DESCRIPTION).execute(StopExecutor)
}

4 changes: 1 addition & 3 deletions pumpkin/src/command/commands/cmd_teleport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
Expand Down
19 changes: 11 additions & 8 deletions pumpkin/src/command/commands/cmd_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down Expand Up @@ -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)),
),
)
}
27 changes: 12 additions & 15 deletions pumpkin/src/command/commands/cmd_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
),
)
}
7 changes: 4 additions & 3 deletions pumpkin/src/command/dispatcher.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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));
}
Expand Down
4 changes: 2 additions & 2 deletions pumpkin/src/command/tree_builder.rs
Original file line number Diff line number Diff line change
@@ -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`].
Expand Down

0 comments on commit d4b1a5f

Please sign in to comment.