diff --git a/pumpkin-protocol/src/client/play/c_command_suggestions.rs b/pumpkin-protocol/src/client/play/c_command_suggestions.rs index 91f617d4..eb50314a 100644 --- a/pumpkin-protocol/src/client/play/c_command_suggestions.rs +++ b/pumpkin-protocol/src/client/play/c_command_suggestions.rs @@ -53,7 +53,7 @@ pub struct CommandSuggestion<'a> { impl<'a> CommandSuggestion<'a> { pub fn new(suggestion: String, tooltip: Option>) -> Self { Self { - suggestion: suggestion, + suggestion, tooltip, } } diff --git a/pumpkin/src/command/args/arg_bossbar_color.rs b/pumpkin/src/command/args/arg_bossbar_color.rs index 4d2904e2..664264ea 100644 --- a/pumpkin/src/command/args/arg_bossbar_color.rs +++ b/pumpkin/src/command/args/arg_bossbar_color.rs @@ -57,7 +57,7 @@ impl ArgumentConsumer for BossbarColorArgumentConsumer { let colors = ["blue", "green", "pink", "purple", "red", "white", "yellow"]; let suggestions: Vec = colors .iter() - .map(|color| CommandSuggestion::new(color.to_string(), None)) + .map(|color| CommandSuggestion::new((*color).to_string(), None)) .collect(); Ok(Some(suggestions)) } diff --git a/pumpkin/src/command/args/arg_bossbar_style.rs b/pumpkin/src/command/args/arg_bossbar_style.rs index e48dc232..6d3b2d44 100644 --- a/pumpkin/src/command/args/arg_bossbar_style.rs +++ b/pumpkin/src/command/args/arg_bossbar_style.rs @@ -61,7 +61,7 @@ impl ArgumentConsumer for BossbarStyleArgumentConsumer { ]; let suggestions: Vec = styles .iter() - .map(|style| CommandSuggestion::new(style.to_string(), None)) + .map(|style| CommandSuggestion::new((*style).to_string(), None)) .collect(); Ok(Some(suggestions)) } diff --git a/pumpkin/src/command/args/mod.rs b/pumpkin/src/command/args/mod.rs index 643697bd..f1fa8f85 100644 --- a/pumpkin/src/command/args/mod.rs +++ b/pumpkin/src/command/args/mod.rs @@ -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; diff --git a/pumpkin/src/command/commands/cmd_bossbar.rs b/pumpkin/src/command/commands/cmd_bossbar.rs index 2bbf3a4a..25e449a7 100644 --- a/pumpkin/src/command/commands/cmd_bossbar.rs +++ b/pumpkin/src/command/commands/cmd_bossbar.rs @@ -498,7 +498,7 @@ fn value_consumer() -> BoundedNumArgumentConsumer { 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( diff --git a/pumpkin/src/command/commands/cmd_clear.rs b/pumpkin/src/command/commands/cmd_clear.rs index d6fc38aa..b948d0df 100644 --- a/pumpkin/src/command/commands/cmd_clear.rs +++ b/pumpkin/src/command/commands/cmd_clear.rs @@ -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)) diff --git a/pumpkin/src/command/commands/cmd_fill.rs b/pumpkin/src/command/commands/cmd_fill.rs index d27e399a..140e8729 100644 --- a/pumpkin/src/command/commands/cmd_fill.rs +++ b/pumpkin/src/command/commands/cmd_fill.rs @@ -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( diff --git a/pumpkin/src/command/commands/cmd_gamemode.rs b/pumpkin/src/command/commands/cmd_gamemode.rs index 2d809adb..2b627862 100644 --- a/pumpkin/src/command/commands/cmd_gamemode.rs +++ b/pumpkin/src/command/commands/cmd_gamemode.rs @@ -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) diff --git a/pumpkin/src/command/commands/cmd_give.rs b/pumpkin/src/command/commands/cmd_give.rs index 594b1893..cdc3334b 100644 --- a/pumpkin/src/command/commands/cmd_give.rs +++ b/pumpkin/src/command/commands/cmd_give.rs @@ -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( diff --git a/pumpkin/src/command/commands/cmd_help.rs b/pumpkin/src/command/commands/cmd_help.rs index 35eda17b..c0ab3eb7 100644 --- a/pumpkin/src/command/commands/cmd_help.rs +++ b/pumpkin/src/command/commands/cmd_help.rs @@ -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)) @@ -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)) diff --git a/pumpkin/src/command/commands/cmd_kick.rs b/pumpkin/src/command/commands/cmd_kick.rs index 24ca8fbc..8d77bf3d 100644 --- a/pumpkin/src/command/commands/cmd_kick.rs +++ b/pumpkin/src/command/commands/cmd_kick.rs @@ -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)) } diff --git a/pumpkin/src/command/commands/cmd_kill.rs b/pumpkin/src/command/commands/cmd_kill.rs index 0851d6d9..2b36b0c4 100644 --- a/pumpkin/src/command/commands/cmd_kill.rs +++ b/pumpkin/src/command/commands/cmd_kill.rs @@ -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)) diff --git a/pumpkin/src/command/commands/cmd_list.rs b/pumpkin/src/command/commands/cmd_list.rs index 7bba9d0b..bbcc3641 100644 --- a/pumpkin/src/command/commands/cmd_list.rs +++ b/pumpkin/src/command/commands/cmd_list.rs @@ -55,6 +55,6 @@ fn get_player_names(players: Vec>) -> String { names } -pub fn init_command_tree<'a>() -> CommandTree { +pub fn init_command_tree() -> CommandTree { CommandTree::new(NAMES, DESCRIPTION).execute(ListExecutor) } diff --git a/pumpkin/src/command/commands/cmd_pumpkin.rs b/pumpkin/src/command/commands/cmd_pumpkin.rs index e16f8843..a76a1be9 100644 --- a/pumpkin/src/command/commands/cmd_pumpkin.rs +++ b/pumpkin/src/command/commands/cmd_pumpkin.rs @@ -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) } diff --git a/pumpkin/src/command/commands/cmd_say.rs b/pumpkin/src/command/commands/cmd_say.rs index 63f16894..fad4b64b 100644 --- a/pumpkin/src/command/commands/cmd_say.rs +++ b/pumpkin/src/command/commands/cmd_say.rs @@ -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)), diff --git a/pumpkin/src/command/commands/cmd_seed.rs b/pumpkin/src/command/commands/cmd_seed.rs index ee9bd2ba..c4ffc375 100644 --- a/pumpkin/src/command/commands/cmd_seed.rs +++ b/pumpkin/src/command/commands/cmd_seed.rs @@ -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) diff --git a/pumpkin/src/command/commands/cmd_setblock.rs b/pumpkin/src/command/commands/cmd_setblock.rs index f7abac27..8b7cf973 100644 --- a/pumpkin/src/command/commands/cmd_setblock.rs +++ b/pumpkin/src/command/commands/cmd_setblock.rs @@ -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( diff --git a/pumpkin/src/command/commands/cmd_stop.rs b/pumpkin/src/command/commands/cmd_stop.rs index 20f19f8a..9e3ada0b 100644 --- a/pumpkin/src/command/commands/cmd_stop.rs +++ b/pumpkin/src/command/commands/cmd_stop.rs @@ -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), ) diff --git a/pumpkin/src/command/commands/cmd_teleport.rs b/pumpkin/src/command/commands/cmd_teleport.rs index a21d9054..d9468147 100644 --- a/pumpkin/src/command/commands/cmd_teleport.rs +++ b/pumpkin/src/command/commands/cmd_teleport.rs @@ -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( diff --git a/pumpkin/src/command/commands/cmd_time.rs b/pumpkin/src/command/commands/cmd_time.rs index 81bec7cf..669a3294 100644 --- a/pumpkin/src/command/commands/cmd_time.rs +++ b/pumpkin/src/command/commands/cmd_time.rs @@ -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( diff --git a/pumpkin/src/command/commands/cmd_transfer.rs b/pumpkin/src/command/commands/cmd_transfer.rs index 6b7326f9..e35b0329 100644 --- a/pumpkin/src/command/commands/cmd_transfer.rs +++ b/pumpkin/src/command/commands/cmd_transfer.rs @@ -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) diff --git a/pumpkin/src/command/commands/cmd_worldborder.rs b/pumpkin/src/command/commands/cmd_worldborder.rs index f252fcfc..b52ac6b5 100644 --- a/pumpkin/src/command/commands/cmd_worldborder.rs +++ b/pumpkin/src/command/commands/cmd_worldborder.rs @@ -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( diff --git a/pumpkin/src/command/dispatcher.rs b/pumpkin/src/command/dispatcher.rs index bee8c7f0..4d1bb943 100644 --- a/pumpkin/src/command/dispatcher.rs +++ b/pumpkin/src/command/dispatcher.rs @@ -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)] @@ -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)) => { @@ -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(()); } } @@ -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), } @@ -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() { diff --git a/pumpkin/src/command/mod.rs b/pumpkin/src/command/mod.rs index cbb61498..11eea197 100644 --- a/pumpkin/src/command/mod.rs +++ b/pumpkin/src/command/mod.rs @@ -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()); diff --git a/pumpkin/src/command/tree.rs b/pumpkin/src/command/tree.rs index 423bf0d1..8f54f949 100644 --- a/pumpkin/src/command/tree.rs +++ b/pumpkin/src/command/tree.rs @@ -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>;