mirror of
https://github.com/Pumpkin-MC/Pumpkin.git
synced 2026-08-30 20:14:23 +00:00
Add more events to the Plugin API (#552)
* Add PlayerChangeWorld event * Fix docs * Add PlayerGamemodeChange event * Add PlayerLogin event * Fix clippy * Fix docs * Add PlayerChat event * Fix some event impls * Post-merge issues * Add PlayerCommandSend event * Fix PlayerCommandSend event * Fix PlayerLogin event docs * Add PlayerMove event * Implement PlayerCommandSend event * Implement player position sync when move event cancelled * Add PlayerMove event to handle_position_rotation * Fix docs * Implement PlayerTeleport event * Add ServerBroadcast event * Fix some event impls * Add ServerPluginEnable event * Add ServerPluginDisable event * Implement plugin enable/disable events * Add ServerComand event * Fix clippy * Add teleport method to player * Fix player teleport event impl * Fix imports * remove not needed clones * Fix clippy * Fix formatting * Respect server.defaultgamemode --------- Co-authored-by: Alexander Medvedev <lilalexmed@proton.me>
This commit is contained in:
45
pumpkin/src/plugin/api/events/player/player_command_send.rs
Normal file
45
pumpkin/src/plugin/api/events/player/player_command_send.rs
Normal file
@@ -0,0 +1,45 @@
|
||||
use pumpkin_macros::{Event, cancellable};
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::entity::player::Player;
|
||||
|
||||
use super::PlayerEvent;
|
||||
|
||||
/// An event that occurs when a player executes a command
|
||||
///
|
||||
/// If the event is cancelled, the command will not be executed.
|
||||
///
|
||||
/// This event contains information about the player, and the command being executed.
|
||||
#[cancellable]
|
||||
#[derive(Event, Clone)]
|
||||
pub struct PlayerCommandSendEvent {
|
||||
/// The player who is executing the command.
|
||||
pub player: Arc<Player>,
|
||||
|
||||
/// The command being executed
|
||||
pub command: String,
|
||||
}
|
||||
|
||||
impl PlayerCommandSendEvent {
|
||||
/// Creates a new instance of `PlayerCommandSendEvent`.
|
||||
///
|
||||
/// # Arguments
|
||||
/// - `player`: A reference to the player running a command.
|
||||
/// - `command`: The command being executed.
|
||||
///
|
||||
/// # Returns
|
||||
/// A new instance of `PlayerCommandSendEvent`.
|
||||
pub fn new(player: Arc<Player>, command: String) -> Self {
|
||||
Self {
|
||||
player,
|
||||
command,
|
||||
cancelled: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl PlayerEvent for PlayerCommandSendEvent {
|
||||
fn get_player(&self) -> &Arc<Player> {
|
||||
&self.player
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user