Docs » API reference » Player

Player

A player in the world: their body, health, bag, gear, coins, progress and team.

A Player is someone in the world right now. Their lasting id comes from their store account through Epic and is the same every time they join, so save the id, not the Player, to remember someone. Once they leave, the Player is gone and its calls fail. What the server keeps of them is a PlayerProfile.

Reading needs nothing. Changing a player's bag, gear, coins, progress or team needs player_data.

A handle to something in the game. Once that thing is gone, its calls fail with Gone. You get one from server.players(), server.player(id), and events.

Methods

MethodDescription
fn id(&self) -> Result<PlayerId>String id()Their lasting ID.
fn name(&self) -> Result<String>String name()Their store account's name.
fn called(&self) -> Result<String>String called()What everyone sees: their name, with a #number while another player has the same name.
fn number(&self) -> Result<i64>long number()Their number in this session, as the console's list shows it (from 1).
fn store(&self) -> Result<Store>Store store()Which store their account is from.
fn position(&self) -> Result<Place>Place position()Where their feet are.
fn facing(&self) -> Result<f64>double facing()The way their body faces, in degrees (0 north, 90 east).
fn head(&self) -> Result<Place>Place head()Where their head is.
fn left_hand(&self) -> Result<Hand>Hand leftHand()Their left hand.
fn right_hand(&self) -> Result<Hand>Hand rightHand()Their right hand.
fn health(&self) -> Result<f64>double health()Their health now.
fn max_health(&self) -> Result<f64>double maxHealth()Their most health.
fn hunger(&self) -> Result<f64>double hunger()How fed they are, 0 to 1.
fn breath(&self) -> Result<f64>double breath()Breath left under water, 0 to 1.
fn fainted(&self) -> Result<bool>boolean fainted()Whether they have fainted.
fn in_battle(&self) -> Result<bool>boolean inBattle()Whether they are in a turn-based battle.
fn sitting(&self) -> Result<bool>boolean sitting()Whether they are sitting.
fn town(&self) -> Result<Option<Town>>Optional<Town> town()The town they are in.
fn dungeon(&self) -> Result<Option<Dungeon>>Optional<Dungeon> dungeon()The dungeon they are down in.
fn coins(&self) -> Result<i64>long coins()Their coins.
fn pack_colour(&self) -> Result<PackColour>PackColour packColour()Their backpack's colour.
fn played(&self) -> Result<Duration>double played()How long they have played in this world.
fn bag(&self) -> Result<Bag>Bag bag()What they carry.
fn equipment(&self) -> Result<Equipment>Equipment equipment()What they wear and hold ready.
fn professions(&self) -> Result<Professions>Professions professions()Their twelve professions.
fn team(&self) -> Result<Team>Team team()Their Voxelmon.
fn companion(&self) -> Result<Option<Creature>>Optional<Creature> companion()Their Voxelmon out of its cube.
fn teleport(&self, place: Place) -> Result<()>void teleport(Place place)Moves them there at once.
fn teleport_facing(&self, place: Place, facing: f64) -> Result<()>void teleportFacing(Place place, double facing)Moves them and turns them to face facing (degrees clockwise from north): their view on their headset turns with them, once, as a snap turn would.
fn heal(&self, amount: f64) -> Result<()>void heal(double amount)Gives back health, up to their most.
fn damage(&self, amount: f64) -> Result<()>void damage(double amount)Hurts them (PlayerDamaging comes with cause PLUGIN; not in creative).
fn set_hunger(&self, value: f64) -> Result<()>void setHunger(double value)Sets how fed they are, 0 to 1.
fn revive(&self) -> Result<()>void revive()Gets a fainted player up where they are.
fn set_coins(&self, coins: i64) -> Result<()>void setCoins(long coins) player_dataSets their coins.
fn add_coins(&self, coins: i64) -> Result<()>void addCoins(long coins) player_dataGives coins (a negative number takes them, never below nothing).
fn set_pack_colour(&self, colour: PackColour) -> Result<()>void setPackColour(PackColour colour) player_dataColours their backpack.
fn home(&self) -> Result<Option<Place>>Optional<Place> home()Where they wake after fainting, if they slept in a bed.
fn set_home(&self, place: Place) -> Result<()>void setHome(Place place) player_dataSets where they wake.
fn has_permission(&self, permission: &str) -> Result<bool>boolean hasPermission(String permission)Whether they have a permission (Permissions).
fn notice(&self, text: &str) -> Result<()>void notice(String text)A short notice by their watch.
fn banner(&self, banner: Banner) -> Result<()>void banner(Banner banner)A large banner before them.
fn play_sound(&self, sound: Sound) -> Result<()>void playSound(Sound sound)A sound only they hear.
fn open_menu(&self, menu: Menu) -> Result<()>void openMenu(Menu menu)Shows them a menu (Menu).
fn close_menu(&self) -> Result<()>void closeMenu()Closes any plugin menu they have open.
fn set_wrist_tab(&self, slot: i64, menu: Option<Menu>, title: &str, icon: Option<ItemType>) -> Result<()>void setWristTab(long slot, Menu menu, String title, ItemType icon)Puts a server tab on their watch (slot 0 or 1): the menu's first tab, under this title (at most 16 letters) and icon. None takes the slot's tab away. See Hud.
fn kick(&self, reason: &str) -> Result<()>void kick(String reason)Puts them out with a reason. They may join again.
fn block(&self, reason: &str) -> Result<()>void block(String reason)Puts them out and keeps them out.

PlayerProfile

A player who has played here, whether in the world now or not.

Plain data, copied between the server and the plugin.

FieldDescription
id: PlayerIdString id()Their lasting ID.
name: StringString name()Their name when last seen.
first_joined: Timelong firstJoined()When they first joined.
last_seen: Timelong lastSeen()When they last left (now, if in the world).
blocked: boolboolean blocked()Whether they are on the blocked list.
online: boolboolean online()Whether they are in the world now.

Hand

One of a player's hands.

Plain data, copied between the server and the plugin.

FieldDescription
position: PlacePlace position()Where it is.
turn: TurnTurn turn()How it is turned.
holding: Option<ItemStack>Optional<ItemStack> holding()What it holds.

HandSide

Left or right.

One of a fixed set of values.

ValueMeaning
HandSide::LeftHandSide.LEFTThe left hand.
HandSide::RightHandSide.RIGHTThe right hand.

PackColour

A backpack's colour.

One of a fixed set of values.

ValueMeaning
PackColour::TanPackColour.TANTan, the first pack.
PackColour::RedPackColour.REDRed.
PackColour::BluePackColour.BLUEBlue.
PackColour::GreenPackColour.GREENGreen.
PackColour::GoldPackColour.GOLDGold.
PackColour::VioletPackColour.VIOLETViolet.
PackColour::OrangePackColour.ORANGEOrange.
PackColour::PinkPackColour.PINKPink.

Events

Related events: PlayerJoining, PlayerJoined, PlayerLeft, PlayerDamaging, PlayerFainted, PlayerRespawning, PlayerMovedBlock, CoinsChanged.