Struct Player

Source
pub struct Player {
    pub name: String,
    pub uuid: String,
    pub skin_url: Option<String>,
    pub name_changes: Option<Vec<(u64, String)>>,
}
Expand description

A Player…

Not much more to say

Fields§

§name: String

Player Name

§uuid: String

Player UUID

All lowercase with no dashes

§skin_url: Option<String>

Url of current player skin

§name_changes: Option<Vec<(u64, String)>>

List of all player name changes

Due to API limitations anything before the first name change will be the accounts original name.

Implementations§

Source§

impl Player

Source

pub fn new<T>(name_uuid: T) -> Result<Player, MojangError>
where T: Display,

Make a new player

You can supply the Name or UUID

If you supply the uuid you will automaticly get the skin URL

§Example
// Import Lib
use mojang::Player;

// Make a player with Username
let p = Player::new("Sigma76").unwrap();

// Make a player with UUID
let p2 = Player::new("3c358264b4564bdeab1efe1023db6679").unwrap();
Source

pub fn add_skin(self) -> Result<Player, MojangError>

Add Skin URL to a player

§Example
// Import Lib
use mojang::Player;

// Load Skin Data into Player
let p = Player::new("Sigma76").unwrap().add_skin().unwrap();
Source

pub fn add_name_change(self) -> Result<Player, MojangError>

Add Name History Data to a Player

Required if you want to use player.name_at(n)

§Example
// Import Lib
use mojang::Player;

// Load Name History Data into Player
let p = Player::new("Sigma76").unwrap().add_name_change().unwrap();
Source

pub fn name_at(&self, time: u64) -> Result<String, MojangError>

Get play name at Timestamp (ms)

You must have called add_name_change on the player before useing this

§Example
// Import Lib
use mojang::Player;

// Load Name History Data into Player
let p = Player::new("Sigma76").unwrap().add_name_change().unwrap();

// Get name at timestamp
assert_eq!(p.name_at(16362446560000).unwrap(), "Sigma76");

Trait Implementations§

Source§

impl Debug for Player

Source§

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

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

impl PartialEq for Player

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Player

Source§

impl StructuralPartialEq for Player

Auto Trait Implementations§

§

impl Freeze for Player

§

impl RefUnwindSafe for Player

§

impl Send for Player

§

impl Sync for Player

§

impl Unpin for Player

§

impl UnwindSafe for Player

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, 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> Same for T

Source§

type Output = T

Should always be Self
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<T> ErasedDestructor for T
where T: 'static,