-
-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
323 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,44 @@ | ||
use async_trait::async_trait; | ||
use pumpkin_inventory::OpenContainer; | ||
|
||
use crate::commands::tree::CommandTree; | ||
|
||
use super::RunFunctionType; | ||
|
||
const NAMES: [&str; 2] = ["echest", "enderchest"]; | ||
|
||
const DESCRIPTION: &str = | ||
"Show your personal enderchest (this command is used for testing container behaviour)"; | ||
|
||
#[allow(unused_variables)] | ||
struct EchestExecutor {} | ||
|
||
pub fn init_command_tree<'a>() -> CommandTree<'a> { | ||
CommandTree::new(NAMES, DESCRIPTION).execute(&|sender, server, _| { | ||
#[async_trait] | ||
impl RunFunctionType for EchestExecutor { | ||
async fn execute( | ||
&self, | ||
sender: &mut super::CommandSender, | ||
server: &crate::server::Server, | ||
_args: &super::tree::ConsumedArgs, | ||
) -> Result<(), super::dispatcher::InvalidTreeError> { | ||
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; | ||
// match open_containers.get_mut(&0) { | ||
// Some(ender_chest) => { | ||
// ender_chest.add_player(entity_id); | ||
// } | ||
// None => { | ||
// let open_container = OpenContainer::empty(entity_id); | ||
// open_containers.insert(0, open_container); | ||
// } | ||
// } | ||
// } | ||
// player.open_container(server, "minecraft:generic_9x3"); | ||
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::empty(entity_id); | ||
open_containers.insert(0, open_container); | ||
} | ||
} | ||
player.open_container(server, "minecraft:generic_9x3").await; | ||
} | ||
|
||
Ok(()) | ||
}) | ||
} | ||
} | ||
|
||
pub fn init_command_tree<'a>() -> CommandTree<'a> { | ||
CommandTree::new(NAMES, DESCRIPTION).execute(&EchestExecutor {}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,45 @@ | ||
use async_trait::async_trait; | ||
use pumpkin_core::text::color::NamedColor; | ||
use pumpkin_core::text::TextComponent; | ||
|
||
use crate::commands::arg_player::parse_arg_player; | ||
use crate::commands::tree::CommandTree; | ||
use crate::commands::tree_builder::argument; | ||
|
||
use super::arg_player::consume_arg_player; | ||
use super::RunFunctionType; | ||
|
||
const NAMES: [&str; 1] = ["kick"]; | ||
const DESCRIPTION: &str = "Kicks the target player from the server."; | ||
|
||
const ARG_TARGET: &str = "target"; | ||
|
||
#[expect(unused)] | ||
struct KickExecutor {} | ||
|
||
#[async_trait] | ||
impl RunFunctionType for KickExecutor { | ||
async fn execute( | ||
&self, | ||
sender: &mut super::CommandSender, | ||
server: &crate::server::Server, | ||
args: &super::tree::ConsumedArgs, | ||
) -> Result<(), super::dispatcher::InvalidTreeError> { | ||
let target = parse_arg_player(sender, server, ARG_TARGET, args)?; | ||
target | ||
.kick(TextComponent::text("Kicked by an operator")) | ||
.await; | ||
|
||
sender | ||
.send_message( | ||
TextComponent::text("Player has been kicked.").color_named(NamedColor::Blue), | ||
) | ||
.await; | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
pub fn init_command_tree<'a>() -> CommandTree<'a> { | ||
CommandTree::new(NAMES, DESCRIPTION).with_child( | ||
argument(ARG_TARGET, consume_arg_player).execute(&|sender, server, args| { | ||
let target = parse_arg_player(sender, server, ARG_TARGET, args)?; | ||
// target.kick(TextComponent::text("Kicked by an operator")); | ||
|
||
// sender.send_message( | ||
// TextComponent::text("Player has been kicked.").color_named(NamedColor::Blue), | ||
// ); | ||
|
||
Ok(()) | ||
}), | ||
) | ||
CommandTree::new(NAMES, DESCRIPTION) | ||
.with_child(argument(ARG_TARGET, consume_arg_player).execute(&KickExecutor {})) | ||
} |
Oops, something went wrong.