Added Help command back
I just was to lazy and wanted to get it working fast, Now help is back
This commit is contained in:
parent
3d14e1310b
commit
870059a317
@ -1,74 +1,70 @@
|
|||||||
// use crate::commands::dispatcher::InvalidTreeError::InvalidConsumptionError;
|
use crate::commands::dispatcher::InvalidTreeError::InvalidConsumptionError;
|
||||||
// use crate::commands::dispatcher::{CommandDispatcher, InvalidTreeError};
|
use crate::commands::dispatcher::{CommandDispatcher, InvalidTreeError};
|
||||||
// use crate::commands::tree::{Command, CommandTree, ConsumedArgs, RawArgs};
|
use crate::commands::tree::{Command, CommandTree, ConsumedArgs, RawArgs};
|
||||||
// use crate::commands::tree_builder::argument;
|
use crate::commands::tree_builder::argument;
|
||||||
// use crate::commands::{CommandSender};
|
use crate::commands::CommandSender;
|
||||||
// use pumpkin_core::text::TextComponent;
|
use pumpkin_core::text::TextComponent;
|
||||||
|
|
||||||
// const NAMES: [&str; 3] = ["help", "h", "?"];
|
const NAMES: [&str; 3] = ["help", "h", "?"];
|
||||||
|
|
||||||
// const DESCRIPTION: &str = "Print a help message.";
|
const DESCRIPTION: &str = "Print a help message.";
|
||||||
|
|
||||||
// const ARG_COMMAND: &str = "command";
|
const ARG_COMMAND: &str = "command";
|
||||||
|
|
||||||
// fn consume_arg_command(_src: &CommandSender, args: &mut RawArgs) -> Option<String> {
|
fn consume_arg_command(_src: &CommandSender, _args: &mut RawArgs) -> Option<String> {
|
||||||
// let s = args.pop()?;
|
// let s = args.pop()?;
|
||||||
|
|
||||||
// let dispatcher = DISPATCHER.get_or_init(dispatcher_init);
|
|
||||||
|
|
||||||
// dispatcher.get_tree(s).ok().map(|tree| tree.names[0].into())
|
// dispatcher.get_tree(s).ok().map(|tree| tree.names[0].into())
|
||||||
// }
|
// TODO
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
// fn parse_arg_command<'a>(
|
fn parse_arg_command<'a>(
|
||||||
// consumed_args: &'a ConsumedArgs,
|
consumed_args: &'a ConsumedArgs,
|
||||||
// dispatcher: &'a CommandDispatcher,
|
dispatcher: &'a CommandDispatcher,
|
||||||
// ) -> Result<&'a CommandTree<'a>, InvalidTreeError> {
|
) -> Result<&'a CommandTree<'a>, InvalidTreeError> {
|
||||||
// let command_name = consumed_args
|
let command_name = consumed_args
|
||||||
// .get(ARG_COMMAND)
|
.get(ARG_COMMAND)
|
||||||
// .ok_or(InvalidConsumptionError(None))?;
|
.ok_or(InvalidConsumptionError(None))?;
|
||||||
|
|
||||||
// dispatcher
|
dispatcher
|
||||||
// .get_tree(command_name)
|
.get_tree(command_name)
|
||||||
// .map_err(|_| InvalidConsumptionError(Some(command_name.into())))
|
.map_err(|_| InvalidConsumptionError(Some(command_name.into())))
|
||||||
// }
|
}
|
||||||
|
|
||||||
// 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_COMMAND, consume_arg_command).execute(&|sender, _, args| {
|
argument(ARG_COMMAND, consume_arg_command).execute(&|sender, server, args| {
|
||||||
// let dispatcher = DISPATCHER.get_or_init(dispatcher_init);
|
let tree = parse_arg_command(args, &server.command_dispatcher)?;
|
||||||
|
|
||||||
// let tree = parse_arg_command(args, dispatcher)?;
|
sender.send_message(TextComponent::text(&format!(
|
||||||
|
"{} - {} Usage: {}",
|
||||||
|
tree.names.join("/"),
|
||||||
|
tree.description,
|
||||||
|
tree
|
||||||
|
)));
|
||||||
|
|
||||||
// sender.send_message(TextComponent::text(&format!(
|
Ok(())
|
||||||
// "{} - {} Usage: {}",
|
}),
|
||||||
// tree.names.join("/"),
|
)
|
||||||
// tree.description,
|
.execute(&|sender, server, _args| {
|
||||||
// tree
|
let mut keys: Vec<&str> = server.command_dispatcher.commands.keys().copied().collect();
|
||||||
// )));
|
keys.sort();
|
||||||
|
|
||||||
// Ok(())
|
for key in keys {
|
||||||
// }),
|
let Command::Tree(tree) = &server.command_dispatcher.commands[key] else {
|
||||||
// )
|
continue;
|
||||||
// .execute(&|sender, _, _args| {
|
};
|
||||||
// let dispatcher = DISPATCHER.get_or_init(dispatcher_init);
|
|
||||||
|
|
||||||
// let mut keys: Vec<&str> = dispatcher.commands.keys().copied().collect();
|
sender.send_message(TextComponent::text(&format!(
|
||||||
// keys.sort();
|
"{} - {} Usage: {}",
|
||||||
|
tree.names.join("/"),
|
||||||
|
tree.description,
|
||||||
|
tree
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
// for key in keys {
|
Ok(())
|
||||||
// let Command::Tree(tree) = &dispatcher.commands[key] else {
|
})
|
||||||
// continue;
|
}
|
||||||
// };
|
|
||||||
|
|
||||||
// sender.send_message(TextComponent::text(&format!(
|
|
||||||
// "{} - {} Usage: {}",
|
|
||||||
// tree.names.join("/"),
|
|
||||||
// tree.description,
|
|
||||||
// tree
|
|
||||||
// )));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Ok(())
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|||||||
@ -67,7 +67,7 @@ pub fn default_dispatcher<'a>() -> CommandDispatcher<'a> {
|
|||||||
dispatcher.register(cmd_pumpkin::init_command_tree());
|
dispatcher.register(cmd_pumpkin::init_command_tree());
|
||||||
dispatcher.register(cmd_gamemode::init_command_tree());
|
dispatcher.register(cmd_gamemode::init_command_tree());
|
||||||
dispatcher.register(cmd_stop::init_command_tree());
|
dispatcher.register(cmd_stop::init_command_tree());
|
||||||
// dispatcher.register(cmd_help::init_command_tree());
|
dispatcher.register(cmd_help::init_command_tree());
|
||||||
|
|
||||||
dispatcher
|
dispatcher
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,7 +44,6 @@ pub(crate) struct CommandTree<'a> {
|
|||||||
pub(crate) nodes: Vec<Node<'a>>,
|
pub(crate) nodes: Vec<Node<'a>>,
|
||||||
pub(crate) children: Vec<usize>,
|
pub(crate) children: Vec<usize>,
|
||||||
pub(crate) names: Vec<&'a str>,
|
pub(crate) names: Vec<&'a str>,
|
||||||
#[expect(dead_code)]
|
|
||||||
pub(crate) description: &'a str,
|
pub(crate) description: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user