EventContext

Struct EventContext 

Source
pub struct EventContext<'a, T> {
    pub data: &'a T,
    /* private fields */
}
Expand description

A smart wrapper for a server event.

This struct provides read-only access to the event’s data and methods to mutate or cancel it.

Fields§

§data: &'a T

Implementations§

Source§

impl<'a, T> EventContext<'a, T>

Source

pub fn cancel(&mut self)

Cancels the event.

The server’s default handler will not run.

Source§

impl<'a> EventContext<'a, ChatEvent>

Source

pub fn set_message(&mut self, message: impl Into<Option<String>>)

Sets the message for this event.

Source§

impl<'a> EventContext<'a, BlockBreakEvent>

Source

pub fn set_drops(&mut self, drops: impl Into<Option<ItemStackList>>)

Sets the drops for this event.

Source

pub fn set_xp(&mut self, xp: impl Into<Option<i32>>)

Sets the xp for this event.

Source§

impl<'a> EventContext<'a, PlayerFoodLossEvent>

Source

pub fn set_to(&mut self, to: impl Into<Option<i32>>)

Sets the to for this event.

Source§

impl<'a> EventContext<'a, PlayerHealEvent>

Source

pub fn set_amount(&mut self, amount: impl Into<Option<f64>>)

Sets the amount for this event.

Source§

impl<'a> EventContext<'a, PlayerHurtEvent>

Source

pub fn set_damage(&mut self, damage: impl Into<Option<f64>>)

Sets the damage for this event.

Source

pub fn set_attack_immunity_ms( &mut self, attack_immunity_ms: impl Into<Option<i64>>, )

Sets the attack_immunity_ms for this event.

Source§

impl<'a> EventContext<'a, PlayerDeathEvent>

Source

pub fn set_keep_inventory(&mut self, keep_inventory: impl Into<Option<bool>>)

Sets the keep_inventory for this event.

Source§

impl<'a> EventContext<'a, PlayerRespawnEvent>

Source

pub fn set_position(&mut self, position: impl Into<Option<Vec3>>)

Sets the position for this event.

Source

pub fn set_world(&mut self, world: impl Into<Option<WorldRef>>)

Sets the world for this event.

Source§

impl<'a> EventContext<'a, PlayerAttackEntityEvent>

Source

pub fn set_force(&mut self, force: impl Into<Option<f64>>)

Sets the force for this event.

Source

pub fn set_height(&mut self, height: impl Into<Option<f64>>)

Sets the height for this event.

Source

pub fn set_critical(&mut self, critical: impl Into<Option<bool>>)

Sets the critical for this event.

Source§

impl<'a> EventContext<'a, PlayerExperienceGainEvent>

Source

pub fn set_amount(&mut self, amount: impl Into<Option<i32>>)

Sets the amount for this event.

Source§

impl<'a> EventContext<'a, PlayerLecternPageTurnEvent>

Source

pub fn set_new_page(&mut self, new_page: impl Into<Option<i32>>)

Sets the new_page for this event.

Source§

impl<'a> EventContext<'a, PlayerItemPickupEvent>

Source

pub fn set_item(&mut self, item: impl Into<Option<ItemStack>>)

Sets the item for this event.

Source§

impl<'a> EventContext<'a, PlayerTransferEvent>

Source

pub fn set_address(&mut self, address: impl Into<Option<Address>>)

Sets the address for this event.

Source§

impl<'a> EventContext<'a, WorldExplosionEvent>

Source

pub fn set_entity_uuids(&mut self, entity_uuids: impl Into<Option<StringList>>)

Sets the entity_uuids for this event.

Source

pub fn set_blocks(&mut self, blocks: impl Into<Option<BlockPosList>>)

Sets the blocks for this event.

Source

pub fn set_item_drop_chance(&mut self, item_drop_chance: impl Into<Option<f64>>)

Sets the item_drop_chance for this event.

Source

pub fn set_spawn_fire(&mut self, spawn_fire: impl Into<Option<bool>>)

Sets the spawn_fire for this event.

Auto Trait Implementations§

§

impl<'a, T> Freeze for EventContext<'a, T>

§

impl<'a, T> RefUnwindSafe for EventContext<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for EventContext<'a, T>
where T: Sync,

§

impl<'a, T> Sync for EventContext<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for EventContext<'a, T>

§

impl<'a, T> UnwindSafe for EventContext<'a, T>
where T: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more