Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
urisinger committed Dec 26, 2024
1 parent 5676ca2 commit 14dea74
Show file tree
Hide file tree
Showing 25 changed files with 31 additions and 32 deletions.
2 changes: 1 addition & 1 deletion pumpkin-protocol/src/client/play/c_command_suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub struct CommandSuggestion<'a> {
impl<'a> CommandSuggestion<'a> {
pub fn new(suggestion: String, tooltip: Option<TextComponent<'static>>) -> Self {
Self {
suggestion: suggestion,
suggestion,
tooltip,
}
}
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/command/args/arg_bossbar_color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl ArgumentConsumer for BossbarColorArgumentConsumer {
let colors = ["blue", "green", "pink", "purple", "red", "white", "yellow"];
let suggestions: Vec<CommandSuggestion> = colors
.iter()
.map(|color| CommandSuggestion::new(color.to_string(), None))
.map(|color| CommandSuggestion::new((*color).to_string(), None))
.collect();
Ok(Some(suggestions))
}
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/command/args/arg_bossbar_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl ArgumentConsumer for BossbarStyleArgumentConsumer {
];
let suggestions: Vec<CommandSuggestion> = styles
.iter()
.map(|style| CommandSuggestion::new(style.to_string(), None))
.map(|style| CommandSuggestion::new((*style).to_string(), None))
.collect();
Ok(Some(suggestions))
}
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/command/args/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{borrow::Cow, collections::HashMap, hash::Hash, sync::Arc};
use std::{collections::HashMap, hash::Hash, sync::Arc};

use arg_bounded_num::{NotInBounds, Number};
use async_trait::async_trait;
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/command/commands/cmd_bossbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ fn value_consumer() -> BoundedNumArgumentConsumer<i32> {
BoundedNumArgumentConsumer::new().min(0).name("value")
}

pub fn init_command_tree<'a>() -> CommandTree {
pub fn init_command_tree() -> CommandTree {
CommandTree::new(NAMES, DESCRIPTION)
.with_child(
literal("add").with_child(
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/command/commands/cmd_clear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl CommandExecutor for ClearSelfExecutor {
}

#[allow(clippy::redundant_closure_for_method_calls)] // causes lifetime issues
pub fn init_command_tree<'a>() -> CommandTree {
pub fn init_command_tree() -> CommandTree {
CommandTree::new(NAMES, DESCRIPTION)
.with_child(argument(ARG_TARGET, EntitiesArgumentConsumer).execute(ClearExecutor))
.with_child(require(|sender| sender.is_player()).execute(ClearSelfExecutor))
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/command/commands/cmd_fill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl CommandExecutor for SetblockExecutor {
}
}

pub fn init_command_tree<'a>() -> CommandTree {
pub fn init_command_tree() -> CommandTree {
CommandTree::new(NAMES, DESCRIPTION).with_child(
require(|sender| sender.has_permission_lvl(PermissionLvl::Two) && sender.world().is_some())
.with_child(
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/command/commands/cmd_gamemode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl CommandExecutor for GamemodeTargetPlayer {
}

#[allow(clippy::redundant_closure_for_method_calls)]
pub fn init_command_tree<'a>() -> CommandTree {
pub fn init_command_tree() -> CommandTree {
CommandTree::new(NAMES, DESCRIPTION).with_child(
require(|sender| sender.has_permission_lvl(PermissionLvl::Two)).with_child(
argument(ARG_GAMEMODE, GamemodeArgumentConsumer)
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/command/commands/cmd_give.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl CommandExecutor for GiveExecutor {
}
}

pub fn init_command_tree<'a>() -> CommandTree {
pub fn init_command_tree() -> CommandTree {
CommandTree::new(NAMES, DESCRIPTION).with_child(
require(|sender| sender.has_permission_lvl(PermissionLvl::Two)).with_child(
argument_default_name(PlayersArgumentConsumer).with_child(
Expand Down
4 changes: 2 additions & 2 deletions pumpkin/src/command/commands/cmd_help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl CommandExecutor for BaseHelpExecutor {
.color_named(NamedColor::Gold)
.add_child(TextComponent::text(" - ").color_named(NamedColor::Yellow))
.add_child(
TextComponent::text_string(tree.description.to_owned() + "\n")
TextComponent::text_string(tree.description.clone() + "\n")
.color_named(NamedColor::White),
)
.add_child(TextComponent::text(" Usage: ").color_named(NamedColor::Yellow))
Expand Down Expand Up @@ -221,7 +221,7 @@ impl CommandExecutor for BaseHelpExecutor {
}
}

pub fn init_command_tree<'a>() -> CommandTree {
pub fn init_command_tree() -> CommandTree {
CommandTree::new(NAMES, DESCRIPTION)
.with_child(argument(ARG_COMMAND, CommandTreeArgumentConsumer).execute(CommandHelpExecutor))
.with_child(argument_default_name(page_number_consumer()).execute(BaseHelpExecutor))
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/command/commands/cmd_kick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl CommandExecutor for KickExecutor {
}
}

pub fn init_command_tree<'a>() -> CommandTree {
pub fn init_command_tree() -> CommandTree {
CommandTree::new(NAMES, DESCRIPTION)
.with_child(argument(ARG_TARGET, PlayersArgumentConsumer).execute(KickExecutor))
}
2 changes: 1 addition & 1 deletion pumpkin/src/command/commands/cmd_kill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl CommandExecutor for KillSelfExecutor {
}

#[allow(clippy::redundant_closure_for_method_calls)] // causes lifetime issues
pub fn init_command_tree<'a>() -> CommandTree {
pub fn init_command_tree() -> CommandTree {
CommandTree::new(NAMES, DESCRIPTION)
.with_child(argument(ARG_TARGET, EntitiesArgumentConsumer).execute(KillExecutor))
.with_child(require(|sender| sender.is_player()).execute(KillSelfExecutor))
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/command/commands/cmd_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ fn get_player_names(players: Vec<Arc<Player>>) -> String {
names
}

pub fn init_command_tree<'a>() -> CommandTree {
pub fn init_command_tree() -> CommandTree {
CommandTree::new(NAMES, DESCRIPTION).execute(ListExecutor)
}
2 changes: 1 addition & 1 deletion pumpkin/src/command/commands/cmd_pumpkin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ impl CommandExecutor for PumpkinExecutor {
}
}

pub fn init_command_tree<'a>() -> CommandTree {
pub fn init_command_tree() -> CommandTree {
CommandTree::new(NAMES, DESCRIPTION).execute(PumpkinExecutor)
}
2 changes: 1 addition & 1 deletion pumpkin/src/command/commands/cmd_say.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl CommandExecutor for SayExecutor {
}
}

pub fn init_command_tree<'a>() -> CommandTree {
pub fn init_command_tree() -> CommandTree {
CommandTree::new(NAMES, DESCRIPTION).with_child(
require(|sender| sender.has_permission_lvl(PermissionLvl::Two))
.with_child(argument(ARG_MESSAGE, MsgArgConsumer).execute(SayExecutor)),
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/command/commands/cmd_seed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl CommandExecutor for PumpkinExecutor {
}
}

pub fn init_command_tree<'a>() -> CommandTree {
pub fn init_command_tree() -> CommandTree {
CommandTree::new(NAMES, DESCRIPTION)
.with_child(require(|sender| {
sender.has_permission_lvl(PermissionLvl::Two)
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/command/commands/cmd_setblock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl CommandExecutor for SetblockExecutor {
}
}

pub fn init_command_tree<'a>() -> CommandTree {
pub fn init_command_tree() -> CommandTree {
CommandTree::new(NAMES, DESCRIPTION).with_child(
require(|sender| sender.has_permission_lvl(PermissionLvl::Two) && sender.world().is_some())
.with_child(
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/command/commands/cmd_stop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl CommandExecutor for StopExecutor {
}
}

pub fn init_command_tree<'a>() -> CommandTree {
pub fn init_command_tree() -> CommandTree {
CommandTree::new(NAMES, DESCRIPTION).with_child(
require(|sender| sender.has_permission_lvl(PermissionLvl::Four)).execute(StopExecutor),
)
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/command/commands/cmd_teleport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ impl CommandExecutor for TpSelfToPosExecutor {
}
}

pub fn init_command_tree<'a>() -> CommandTree {
pub fn init_command_tree() -> CommandTree {
CommandTree::new(NAMES, DESCRIPTION).with_child(
require(|sender| sender.has_permission_lvl(PermissionLvl::Two))
.with_child(
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/command/commands/cmd_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl CommandExecutor for TimeChangeExecutor {
}
}

pub fn init_command_tree<'a>() -> CommandTree {
pub fn init_command_tree() -> CommandTree {
CommandTree::new(NAMES, DESCRIPTION).with_child(
require(|sender| sender.has_permission_lvl(PermissionLvl::Two))
.with_child(literal("add").with_child(
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/command/commands/cmd_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl CommandExecutor for TransferTargetPlayer {
}

#[allow(clippy::redundant_closure_for_method_calls)]
pub fn init_command_tree<'a>() -> CommandTree {
pub fn init_command_tree() -> CommandTree {
CommandTree::new(NAMES, DESCRIPTION).with_child(
require(|sender| sender.has_permission_lvl(PermissionLvl::Three)).with_child(
argument(ARG_HOSTNAME, SimpleArgConsumer)
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/command/commands/cmd_worldborder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ impl CommandExecutor for WorldborderWarningTimeExecutor {
}
}

pub fn init_command_tree<'a>() -> CommandTree {
pub fn init_command_tree() -> CommandTree {
CommandTree::new(NAMES, DESCRIPTION)
.with_child(
literal("add").with_child(
Expand Down
13 changes: 6 additions & 7 deletions pumpkin/src/command/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use crate::command::CommandSender;
use crate::error::PumpkinError;
use crate::server::Server;
use pumpkin_core::text::color::{Color, NamedColor};
use std::borrow::Cow;
use std::collections::{HashMap, HashSet};

#[derive(Debug)]
Expand Down Expand Up @@ -103,7 +102,7 @@ impl CommandDispatcher {
// try paths and collect the nodes that fail
// todo: make this more fine-grained
for path in tree.iter_paths() {
match Self::try_find_suggestions_on_path(src, server, &path, &tree, &mut raw_args, cmd)
match Self::try_find_suggestions_on_path(src, server, &path, tree, &mut raw_args, cmd)
.await
{
Err(InvalidConsumption(s)) => {
Expand Down Expand Up @@ -152,7 +151,7 @@ impl CommandDispatcher {

// try paths until fitting path is found
for path in tree.iter_paths() {
if Self::try_is_fitting_path(src, server, &path, &tree, &mut raw_args.clone()).await? {
if Self::try_is_fitting_path(src, server, &path, tree, &mut raw_args.clone()).await? {
return Ok(());
}
}
Expand Down Expand Up @@ -201,14 +200,14 @@ impl CommandDispatcher {
};
}
NodeType::Literal { string, .. } => {
if raw_args.pop() != Some(&string) {
if raw_args.pop() != Some(string) {
return Ok(false);
}
}
NodeType::Argument { consumer, name, .. } => {
match consumer.consume(src, server, raw_args).await {
Some(consumed) => {
parsed_args.insert(&name, consumed);
parsed_args.insert(name, consumed);
}
None => return Ok(false),
}
Expand Down Expand Up @@ -240,14 +239,14 @@ impl CommandDispatcher {
return Ok(None);
}
NodeType::Literal { string, .. } => {
if raw_args.pop() != Some(&string) {
if raw_args.pop() != Some(string) {
return Ok(None);
}
}
NodeType::Argument { consumer, name } => {
match consumer.consume(src, server, raw_args).await {
Some(consumed) => {
parsed_args.insert(&name, consumed);
parsed_args.insert(name, consumed);
}
None => {
return if raw_args.is_empty() {
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl<'a> CommandSender<'a> {
}

#[must_use]
pub fn default_dispatcher<'a>() -> CommandDispatcher {
pub fn default_dispatcher() -> CommandDispatcher {
let mut dispatcher = CommandDispatcher::default();

dispatcher.register(cmd_pumpkin::init_command_tree());
Expand Down
2 changes: 1 addition & 1 deletion pumpkin/src/command/tree.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{args::ArgumentConsumer, CommandExecutor};
use crate::command::CommandSender;
use std::{borrow::Cow, collections::VecDeque, fmt::Debug, rc::Rc, sync::Arc};
use std::{collections::VecDeque, fmt::Debug, sync::Arc};

/// see [`crate::commands::tree_builder::argument`]
pub type RawArgs<'a> = Vec<&'a str>;
Expand Down

0 comments on commit 14dea74

Please sign in to comment.