Class Player
Represents one accepted authenticated player login.
public sealed class Player : ICommandSender, IPermissionHolder
- Inheritance
-
Player
- Implements
- Inherited Members
Properties
Id
Gets the authenticated player identifier.
public Guid Id { get; }
Property Value
Language
Gets the client's selected BCP-47 language.
public string Language { get; }
Property Value
Name
Gets the normalized player name accepted during setup.
public string Name { get; }
Property Value
Skin
Gets the validated Character Creator selection supplied by authentication.
public PlayerSkinSelection? Skin { get; }
Property Value
WorldId
Gets the identifier of the world containing the player's currently active avatar, or null while the player is joining or disconnected.
public Guid? WorldId { get; }
Property Value
- Guid?
Remarks
This is an observational snapshot, not proof that the Player remains in this World. World work must use InCurrentWorldAsync(PlayerAvatarAction) or InWorldAsync(World, PlayerAvatarAction).
Methods
HasPermission(string, bool)
Checks one permission for the authenticated player identifier.
public bool HasPermission(string permission, bool defaultValue)
Parameters
Returns
- bool
The configured result or
defaultValuewhen no service owns it.
InCurrentWorldAsync(PlayerAvatarAction)
Performs synchronous World work against the Player's exact current avatar.
public ValueTask<bool> InCurrentWorldAsync(PlayerAvatarAction action)
Parameters
actionPlayerAvatarAction
Returns
Remarks
The exact World binding is captured when called and queued work never redirects after that binding ends. The Store and Entity are borrowed only for the callback. The callback must not retain them or perform asynchronous work. Expected lifecycle races return false. Admission failures and callback exceptions fault the returned value task.
InCurrentWorldAsync<TState>(TState, PlayerAvatarAction<TState>)
Performs synchronous World work with state against the exact current avatar.
public ValueTask<bool> InCurrentWorldAsync<TState>(TState state, PlayerAvatarAction<TState> action)
Parameters
stateTStateactionPlayerAvatarAction<TState>
Returns
Type Parameters
TState
InWorldAsync(World, PlayerAvatarAction)
Performs synchronous World work only in the exact expected loaded World.
public ValueTask<bool> InWorldAsync(World expectedWorld, PlayerAvatarAction action)
Parameters
expectedWorldWorldactionPlayerAvatarAction
Returns
Remarks
The expected World is a guard, not a routing source. Queued work runs only while the captured binding remains current. The callback must not retain the borrowed Store or Entity.
SendMessage(FormattedMessage)
Sends a localized protocol message to this player's exact active endpoint.
public void SendMessage(FormattedMessage message)
Parameters
messageFormattedMessage
SendMessage(string)
Best-effort sends one chat message to this Player's exact active endpoint.
public void SendMessage(string message)
Parameters
messagestring
Remarks
A concurrent disconnect may reject or drop the message without failing the caller.
TryDisconnectForProtocolViolation()
public bool TryDisconnectForProtocolViolation()
Returns
TrySend(IToClientPacket)
Attempts to send one targeted packet through this login's active connection.
public bool TrySend(IToClientPacket packet)
Parameters
packetIToClientPacket
Returns
Remarks
The packet is sent only through this Player's exact active endpoint. When the endpoint accepts it, the caller must not mutate the packet afterward.