pumpkinplus/modules/mechanics/player/
locator.rs1use crate::{PLUGIN_ID, config::ConfigManager, mechanics::mechanic::Mechanic};
16use pumpkin_plugin_api::{
17 Server,
18 command::{Command, CommandError, CommandNode, CommandSender, ConsumedArgs},
19 commands::CommandHandler,
20 text::TextComponent,
21};
22use serde::{Deserialize, Serialize};
23use std::collections::HashSet;
24
25#[derive(Default)]
27pub struct Locator;
28
29impl Mechanic for Locator {
30 fn enabled(&self) -> bool {
31 ConfigManager::get()
32 .map(|cm| cm.get_config::<LocatorConfig>().enabled)
33 .unwrap_or(true)
34 }
35
36 fn cmds(&self) -> Vec<Command> {
37 let command = Command::new(
38 &["locator".to_string(), "lc".to_string()],
39 "Allows players to personalise their locator bar",
40 );
41 command.then(CommandNode::literal("color").execute(LocatorExecutor));
42 command.then(CommandNode::literal("hex").execute(LocatorExecutor));
43 command.then(CommandNode::literal("reset").execute(LocatorExecutor));
44 vec![command]
45 }
46
47 fn perms(&self) -> HashSet<String> {
48 HashSet::from([format!("{}:command.locator", PLUGIN_ID)])
49 }
50}
51
52struct LocatorExecutor;
53
54impl CommandHandler for LocatorExecutor {
55 fn handle(
56 &self,
57 sender: CommandSender,
58 _server: Server,
59 _args: ConsumedArgs,
60 ) -> Result<i32, CommandError> {
61 sender.send_message(TextComponent::text("Not yet implemented."));
63 Ok(1)
64 }
65}
66
67#[derive(Debug, Default, Clone, Serialize, Deserialize)]
69pub struct LocatorConfig {
70 pub enabled: bool,
72}