mirror of
https://github.com/Pumpkin-MC/Pumpkin.git
synced 2026-08-31 08:22:33 +00:00
adds the /kill command
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
use pumpkin_core::text::{color::NamedColor, TextComponent};
|
||||
use crate::commands::tree::CommandTree;
|
||||
use crate::commands::arg_player::{consume_arg_player, parse_arg_player};
|
||||
use crate::commands::tree::CommandTree;
|
||||
use crate::commands::tree::RawArgs;
|
||||
use crate::commands::CommandSender;
|
||||
use crate::commands::tree_builder::argument;
|
||||
use crate::commands::CommandSender;
|
||||
use pumpkin_core::text::{color::NamedColor, TextComponent};
|
||||
|
||||
const NAMES: [&str; 1] = ["kill"];
|
||||
const DESCRIPTION: &str = "Kills a target player.";
|
||||
@@ -15,21 +15,19 @@ pub fn consume_arg_target(_src: &CommandSender, args: &mut RawArgs) -> Option<St
|
||||
}
|
||||
|
||||
pub(crate) fn init_command_tree<'a>() -> CommandTree<'a> {
|
||||
CommandTree::new(NAMES, DESCRIPTION)
|
||||
.with_child(
|
||||
argument(ARG_TARGET, consume_arg_target)
|
||||
.execute(&|sender, server, args| {
|
||||
let target = parse_arg_player(sender, server, ARG_TARGET, args)?;
|
||||
target.entity.kill();
|
||||
target.send_system_message(TextComponent::text(
|
||||
"You have been killed."
|
||||
).color_named(NamedColor::Red));
|
||||
CommandTree::new(NAMES, DESCRIPTION).with_child(
|
||||
argument(ARG_TARGET, consume_arg_target).execute(&|sender, server, args| {
|
||||
let target = parse_arg_player(sender, server, ARG_TARGET, args)?;
|
||||
target.entity.kill();
|
||||
target.send_system_message(
|
||||
TextComponent::text("You have been killed.").color_named(NamedColor::Red),
|
||||
);
|
||||
|
||||
sender.send_message(TextComponent::text(
|
||||
"Player has been killed."
|
||||
).color_named(NamedColor::Blue));
|
||||
sender.send_message(
|
||||
TextComponent::text("Player has been killed.").color_named(NamedColor::Blue),
|
||||
);
|
||||
|
||||
Ok(())
|
||||
})
|
||||
)
|
||||
Ok(())
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ mod arg_player;
|
||||
mod cmd_echest;
|
||||
mod cmd_gamemode;
|
||||
mod cmd_help;
|
||||
mod cmd_kill;
|
||||
mod cmd_pumpkin;
|
||||
mod cmd_stop;
|
||||
mod cmd_kill;
|
||||
pub mod dispatcher;
|
||||
mod tree;
|
||||
mod tree_builder;
|
||||
|
||||
Reference in New Issue
Block a user