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
impl Player
Sourcepub fn new<T>(name_uuid: T) -> Result<Player, MojangError>where
T: Display,
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();
Sourcepub fn add_skin(self) -> Result<Player, MojangError>
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();
Sourcepub fn add_name_change(self) -> Result<Player, MojangError>
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();
Sourcepub fn name_at(&self, time: u64) -> Result<String, MojangError>
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§
impl Eq for Player
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more