API reference / @jsprismarine/prismarine / playerIdentity
playerIdentity
Interfaces
PlayerIdentity
Defined in: packages/prismarine/src/playerIdentity.ts:26
The three names a login gives a player.
Properties
linkedFrom?
readonlyoptionallinkedFrom?:Subject
Defined in: packages/prismarine/src/playerIdentity.ts:39
The account the player logged in with, when a link made them play as another: see AccountLinks. The other fields are then the primary account's.
name
readonlyname:string
Defined in: packages/prismarine/src/playerIdentity.ts:28
The display name.
subject
readonlysubject:Subject
Defined in: packages/prismarine/src/playerIdentity.ts:34
Who the player is to the permission files: see Subject.
uuid
readonlyuuid:string
Defined in: packages/prismarine/src/playerIdentity.ts:32
The protocol identity, as a UUID string.
xuid
readonlyxuid:string
Defined in: packages/prismarine/src/playerIdentity.ts:30
The Xbox Live id, or an empty string when the login carried none.
Functions
keyOfPlayer()
keyOfPlayer(
player):string
Defined in: packages/prismarine/src/playerIdentity.ts:117
playerKeyOf for a player object, whose getXUID answers null for no XUID.
Parameters
player
The player.
getName
() => string
getSubject?
() => Subject
getXUID
() => string | null
Returns
string
The player's key.
playerKeyOf()
playerKeyOf(
identity):string
Defined in: packages/prismarine/src/playerIdentity.ts:62
The key per-player services and the saved player record use: the XUID, or the name when there is no XUID.
Not the UUID. On an offline-mode server the UUID is drawn per client install, so a returning player on another device would not find their own record, while the name is what they type each time. On an online-mode server the XUID is the verified account and survives a gamertag change, and the UUID is derived from it, so the two give the same answer. The record has been filed under this key since before services existed, and keeping one key for both means a service and the record can never disagree about whose state they hold.
A Java Edition account has no XUID, and its name may be a Bedrock player's too, so it is keyed by its profile UUID, under a java: prefix no name can carry. On an offline-mode server that UUID is the one vanilla derives from the name, so a returning Java player finds their record.
Unique among live players because sameAccount matches on the key as well as the name and the XUID.
Parameters
identity
Pick<PlayerIdentity, "name" | "xuid"> & Partial<Pick<PlayerIdentity, "subject">>
The player's name, XUID and, where known, subject.
Returns
string
The XUID when there is one, a Java account's UUID, otherwise the name.
sameAccount()
sameAccount(
a,b):boolean
Defined in: packages/prismarine/src/playerIdentity.ts:93
Whether two identities belong to the same account, for the purpose of letting only one of them be live at a time.
Any one of the three is enough. The name and XUID cover playerKeyOf for most logins, and the key itself is compared too: an offline login named 123 with no XUID has the key of a player whose XUID is 123, and the two would read and write one saved record. The UUID is what the player list and the operator list are keyed by, so two live players sharing one would collide there. An empty XUID matches nothing: every player on an offline-mode server has one.
A Java login and a Bedrock login are different accounts even when they share a name, unless a link made them one, so the name and XUID are compared only within one edition.
Parameters
a
One identity.
b
The other.
Returns
boolean
True when the two share a name, a non-empty XUID, a UUID or a playerKeyOf key.