Skip to main content

Player

Struct Player 

Source
pub struct Player {
    pub name: String,
}
Expand description

An online player, by name: every action whose first field is player.

Fields§

§name: String

Implementations§

Source§

impl Player

Source

pub fn new(name: impl Into<String>) -> Player

Source

pub fn entity(&self) -> Option<Entity>

The player as an entity (its uuid asked of the server); None offline.

Source§

impl Player

Source

pub fn tellraw(&self, json: impl Arg<String>) -> bool

Sends json (a text component) to player’s chat.

Source§

impl Player

Source

pub fn title( &self, title: impl Arg<String>, subtitle: impl Arg<String>, fade_in: impl Arg<i32>, stay: impl Arg<i32>, fade_out: impl Arg<i32>, ) -> bool

Shows a title (and subtitle) to player; times in ticks.

Source§

impl Player

Source

pub fn actionbar(&self, message: impl Arg<String>) -> bool

Shows message above player’s hotbar.

Source§

impl Player

Source

pub fn actionbar_json(&self, json: impl Arg<String>) -> bool

Shows a text component above player’s hotbar.

Source§

impl Player

Source

pub fn send_to_player( &self, channel: impl Arg<String>, payload: impl Arg<Vec<u8>>, ) -> bool

Sends payload on channel to player (server side).

Source§

impl Player

Source

pub fn give_item(&self, item: impl Arg<String>, count: impl Arg<u32>) -> bool

Gives player count of item.

Source§

impl Player

Source

pub fn teleport(&self, pos: impl Arg<Point>) -> bool

Moves player in its dimension.

Source§

impl Player

Source

pub fn teleport_to_dim( &self, dim: impl Arg<String>, pos: impl Arg<Point>, ) -> bool

Moves player to pos in dim.

Source§

impl Player

Source

pub fn kick(&self, reason: impl Arg<String>) -> bool

Disconnects player.

Source§

impl Player

Source

pub fn set_gamemode(&self, mode: impl Arg<String>) -> bool

Sets player’s game mode (survival, creative, …).

Source§

impl Player

Source

pub fn inventory(&self) -> Vec<SlotStack>

player’s inventory: its stacks, by slot.

Source§

impl Player

Source

pub fn set_slot( &self, slot: impl Arg<u32>, item: impl Arg<String>, count: impl Arg<u32>, ) -> bool

Sets inventory slot of player.

Source§

impl Player

Source

pub fn held_item_nbt(&self) -> Option<String>

The custom data (SNBT) of what player holds.

Source§

impl Player

Source

pub fn set_held_item_nbt(&self, snbt: impl Arg<String>) -> bool

Sets the custom data of what player holds.

Source§

impl Player

Source

pub fn offhand_item_nbt(&self) -> Option<String>

The custom data (SNBT) of player’s offhand stack.

Source§

impl Player

Source

pub fn set_offhand_item_nbt(&self, snbt: impl Arg<String>) -> bool

Sets the custom data of player’s offhand stack.

Source§

impl Player

Source

pub fn slot_item(&self, slot: impl Arg<u32>) -> Option<Stack>

The stack in slot.

Source§

impl Player

Source

pub fn set_slot_item( &self, slot: impl Arg<u32>, item: impl Arg<String>, count: impl Arg<u32>, snbt: impl Arg<String>, ) -> bool

Sets the stack in slot, with custom data.

Source§

impl Player

Source

pub fn add_xp(&self, amount: impl Arg<i32>) -> bool

Gives player experience points.

Source§

impl Player

Source

pub fn set_may_fly(&self, may_fly: impl Arg<bool>) -> bool

Lets player fly (or not).

Source§

impl Player

Source

pub fn info(&self) -> Option<PlayerInfo>

player’s state.

Source§

impl Player

Source

pub fn set_item_cooldown( &self, item: impl Arg<String>, ticks: impl Arg<i32>, ) -> bool

Puts item on cooldown for player.

Source§

impl Player

Source

pub fn place_block_from_slot( &self, slot: impl Arg<u32>, dim: impl Arg<String>, pos: impl Arg<BlockPos>, ) -> bool

Places the block of slot’s stack at pos, as player would.

Source§

impl Player

Source

pub fn play_to_player( &self, sound: impl Arg<String>, volume: impl Arg<f32>, pitch: impl Arg<f32>, ) -> bool

Plays sound to player only.

Trait Implementations§

Source§

impl Clone for Player

Source§

fn clone(&self) -> Player

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Player

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for Player

Source§

impl Hash for Player

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Player

Source§

fn eq(&self, other: &Player) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Player

Auto Trait Implementations§

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> Arg<T> for T

Source§

fn arg(self) -> T

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.