adds the /kill command
This commit is contained in:
parent
100f313c49
commit
f15db29d29
@ -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::arg_player::{consume_arg_player, parse_arg_player};
|
||||||
|
use crate::commands::tree::CommandTree;
|
||||||
use crate::commands::tree::RawArgs;
|
use crate::commands::tree::RawArgs;
|
||||||
use crate::commands::CommandSender;
|
|
||||||
use crate::commands::tree_builder::argument;
|
use crate::commands::tree_builder::argument;
|
||||||
|
use crate::commands::CommandSender;
|
||||||
|
use pumpkin_core::text::{color::NamedColor, TextComponent};
|
||||||
|
|
||||||
const NAMES: [&str; 1] = ["kill"];
|
const NAMES: [&str; 1] = ["kill"];
|
||||||
const DESCRIPTION: &str = "Kills a target player.";
|
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> {
|
pub(crate) fn init_command_tree<'a>() -> CommandTree<'a> {
|
||||||
CommandTree::new(NAMES, DESCRIPTION)
|
CommandTree::new(NAMES, DESCRIPTION).with_child(
|
||||||
.with_child(
|
argument(ARG_TARGET, consume_arg_target).execute(&|sender, server, args| {
|
||||||
argument(ARG_TARGET, consume_arg_target)
|
|
||||||
.execute(&|sender, server, args| {
|
|
||||||
let target = parse_arg_player(sender, server, ARG_TARGET, args)?;
|
let target = parse_arg_player(sender, server, ARG_TARGET, args)?;
|
||||||
target.entity.kill();
|
target.entity.kill();
|
||||||
target.send_system_message(TextComponent::text(
|
target.send_system_message(
|
||||||
"You have been killed."
|
TextComponent::text("You have been killed.").color_named(NamedColor::Red),
|
||||||
).color_named(NamedColor::Red));
|
);
|
||||||
|
|
||||||
sender.send_message(TextComponent::text(
|
sender.send_message(
|
||||||
"Player has been killed."
|
TextComponent::text("Player has been killed.").color_named(NamedColor::Blue),
|
||||||
).color_named(NamedColor::Blue));
|
);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,9 +11,9 @@ mod arg_player;
|
|||||||
mod cmd_echest;
|
mod cmd_echest;
|
||||||
mod cmd_gamemode;
|
mod cmd_gamemode;
|
||||||
mod cmd_help;
|
mod cmd_help;
|
||||||
|
mod cmd_kill;
|
||||||
mod cmd_pumpkin;
|
mod cmd_pumpkin;
|
||||||
mod cmd_stop;
|
mod cmd_stop;
|
||||||
mod cmd_kill;
|
|
||||||
pub mod dispatcher;
|
pub mod dispatcher;
|
||||||
mod tree;
|
mod tree;
|
||||||
mod tree_builder;
|
mod tree_builder;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user