From 7c90ef9f5afd3e778d7a1596503958a672d2dc8a Mon Sep 17 00:00:00 2001 From: Snowiiii Date: Sat, 7 Dec 2024 16:25:07 +0100 Subject: [PATCH] Remove Craft & Ender Chest commands This was a temporary solution. Since https://github.com/Snowiiii/Pumpkin/commit/b82a4e130bba90c97c3adf121c13a2a4fe72c11d now is merged we can remove them --- pumpkin/src/command/commands/cmd_craft.rs | 45 ------------------- pumpkin/src/command/commands/cmd_echest.rs | 46 -------------------- pumpkin/src/command/commands/cmd_flyspeed.rs | 0 pumpkin/src/command/commands/mod.rs | 2 - pumpkin/src/command/mod.rs | 7 +-- 5 files changed, 2 insertions(+), 98 deletions(-) delete mode 100644 pumpkin/src/command/commands/cmd_craft.rs delete mode 100644 pumpkin/src/command/commands/cmd_echest.rs delete mode 100644 pumpkin/src/command/commands/cmd_flyspeed.rs diff --git a/pumpkin/src/command/commands/cmd_craft.rs b/pumpkin/src/command/commands/cmd_craft.rs deleted file mode 100644 index 2ccbf2695..000000000 --- a/pumpkin/src/command/commands/cmd_craft.rs +++ /dev/null @@ -1,45 +0,0 @@ -use async_trait::async_trait; -use pumpkin_inventory::{CraftingTable, OpenContainer, WindowType}; - -use crate::command::{ - args::ConsumedArgs, tree::CommandTree, CommandError, CommandExecutor, CommandSender, -}; -const NAMES: [&str; 1] = ["craft"]; - -const DESCRIPTION: &str = "Open a crafting table"; - -struct CraftingTableExecutor {} - -#[async_trait] -impl CommandExecutor for CraftingTableExecutor { - async fn execute<'a>( - &self, - sender: &mut CommandSender<'a>, - server: &crate::server::Server, - _args: &ConsumedArgs<'a>, - ) -> Result<(), CommandError> { - if let Some(player) = sender.as_player() { - let entity_id = player.entity_id(); - player.open_container.store(Some(1)); - { - let mut open_containers = server.open_containers.write().await; - if let Some(ender_chest) = open_containers.get_mut(&1) { - ender_chest.add_player(entity_id); - } else { - let open_container = - OpenContainer::new_empty_container::(entity_id); - open_containers.insert(1, open_container); - } - } - player - .open_container(server, WindowType::CraftingTable) - .await; - } - - Ok(()) - } -} - -pub fn init_command_tree<'a>() -> CommandTree<'a> { - CommandTree::new(NAMES, DESCRIPTION).execute(&CraftingTableExecutor {}) -} diff --git a/pumpkin/src/command/commands/cmd_echest.rs b/pumpkin/src/command/commands/cmd_echest.rs deleted file mode 100644 index 382778fc8..000000000 --- a/pumpkin/src/command/commands/cmd_echest.rs +++ /dev/null @@ -1,46 +0,0 @@ -use async_trait::async_trait; -use pumpkin_inventory::{Chest, OpenContainer}; - -use crate::command::{ - args::ConsumedArgs, tree::CommandTree, CommandError, CommandExecutor, CommandSender, -}; - -const NAMES: [&str; 2] = ["echest", "enderchest"]; - -const DESCRIPTION: &str = - "Show your personal enderchest (this command is used for testing container behaviour)"; - -struct EchestExecutor; - -#[async_trait] -impl CommandExecutor for EchestExecutor { - async fn execute<'a>( - &self, - sender: &mut CommandSender<'a>, - server: &crate::server::Server, - _args: &ConsumedArgs<'a>, - ) -> Result<(), CommandError> { - if let Some(player) = sender.as_player() { - let entity_id = player.entity_id(); - player.open_container.store(Some(0)); - { - let mut open_containers = server.open_containers.write().await; - if let Some(ender_chest) = open_containers.get_mut(&0) { - ender_chest.add_player(entity_id); - } else { - let open_container = OpenContainer::new_empty_container::(entity_id); - open_containers.insert(0, open_container); - } - } - player - .open_container(server, pumpkin_inventory::WindowType::Generic9x3) - .await; - } - - Ok(()) - } -} - -pub fn init_command_tree<'a>() -> CommandTree<'a> { - CommandTree::new(NAMES, DESCRIPTION).execute(&EchestExecutor) -} diff --git a/pumpkin/src/command/commands/cmd_flyspeed.rs b/pumpkin/src/command/commands/cmd_flyspeed.rs deleted file mode 100644 index e69de29bb..000000000 diff --git a/pumpkin/src/command/commands/mod.rs b/pumpkin/src/command/commands/mod.rs index cbd1cb2cd..6ea8c01a0 100644 --- a/pumpkin/src/command/commands/mod.rs +++ b/pumpkin/src/command/commands/mod.rs @@ -1,7 +1,5 @@ pub mod cmd_bossbar; pub mod cmd_clear; -pub mod cmd_craft; -pub mod cmd_echest; pub mod cmd_fill; pub mod cmd_gamemode; pub mod cmd_give; diff --git a/pumpkin/src/command/mod.rs b/pumpkin/src/command/mod.rs index 09c85c81c..c3f1b67d3 100644 --- a/pumpkin/src/command/mod.rs +++ b/pumpkin/src/command/mod.rs @@ -10,9 +10,8 @@ use crate::world::World; use args::ConsumedArgs; use async_trait::async_trait; use commands::{ - cmd_clear, cmd_craft, cmd_echest, cmd_fill, cmd_gamemode, cmd_give, cmd_help, cmd_kick, - cmd_kill, cmd_list, cmd_pumpkin, cmd_say, cmd_setblock, cmd_stop, cmd_teleport, cmd_time, - cmd_worldborder, + cmd_clear, cmd_fill, cmd_gamemode, cmd_give, cmd_help, cmd_kick, cmd_kill, cmd_list, + cmd_pumpkin, cmd_say, cmd_setblock, cmd_stop, cmd_teleport, cmd_time, cmd_worldborder, }; use dispatcher::CommandError; use pumpkin_core::math::vector3::Vector3; @@ -117,8 +116,6 @@ pub fn default_dispatcher<'a>() -> Arc> { dispatcher.register(cmd_gamemode::init_command_tree()); dispatcher.register(cmd_stop::init_command_tree()); dispatcher.register(cmd_help::init_command_tree()); - dispatcher.register(cmd_echest::init_command_tree()); - dispatcher.register(cmd_craft::init_command_tree()); dispatcher.register(cmd_kill::init_command_tree()); dispatcher.register(cmd_kick::init_command_tree()); dispatcher.register(cmd_worldborder::init_command_tree());