Skip to content

Class MinecraftPlayer

Namespace: Void.Minecraft.Players
Assembly: Void.Minecraft.dll

Represents a connected Java Edition Minecraft player.

public class MinecraftPlayer : IPlayer, IEquatable<IPlayer>, ICommandSource, IAsyncDisposable, IDisposable

Inheritance

objectMinecraftPlayer

Implements

IPlayer, IEquatable<IPlayer>, ICommandSource, IAsyncDisposable, IDisposable

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Constructors

MinecraftPlayer(TcpClient, IPlayerContext, string, DateTimeOffset, ProtocolVersion)

Represents a connected Java Edition Minecraft player.

public MinecraftPlayer(TcpClient client, IPlayerContext context, string remoteEndPoint, DateTimeOffset connectedAt, ProtocolVersion protocolVersion)

Parameters

client TcpClient

The accepted TCP client owned by the player context.

context IPlayerContext

The player-scoped services and network context.

remoteEndPoint string

The preformatted remote endpoint used before a profile name is known.

connectedAt DateTimeOffset

The timestamp at which the connection was accepted.

protocolVersion ProtocolVersion

The Java Edition protocol version detected for the connection.

Properties

Client

Gets the TCP client for the player connection.

public TcpClient Client { get; }

Property Value

TcpClient

ConnectedAt

Gets the timestamp at which the player connected.

public DateTimeOffset ConnectedAt { get; }

Property Value

DateTimeOffset

Context

Gets the context that owns player-scoped services and network resources.

public IPlayerContext Context { get; }

Property Value

IPlayerContext

IdentifiedKey

Gets or sets the identified chat key supplied by protocol versions 1.19 through 1.19.2.

public IdentifiedKey? IdentifiedKey { get; set; }

Property Value

IdentifiedKey?

Name

Gets the player’s display name.

public string Name { get; }

Property Value

string

Remarks

This returns , which prefers the authenticated profile username when one is available and otherwise falls back to the remote endpoint text.

Phase

Gets or sets the current protocol phase of the player connection.

public Phase Phase { get; set; }

Property Value

Phase

Profile

Gets or sets the player’s game profile after it becomes available.

public GameProfile? Profile { get; set; }

Property Value

GameProfile?

ProtocolVersion

Gets the detected Java Edition protocol version.

public ProtocolVersion ProtocolVersion { get; }

Property Value

ProtocolVersion

RemoteEndPoint

Gets the formatted remote endpoint captured when the player connected.

public string RemoteEndPoint { get; }

Property Value

string

Methods

Dispose()

Disposes the player context and suppresses finalization for this instance.

public void Dispose()

DisposeAsync()

Asynchronously disposes the player context and suppresses finalization for this instance.

public ValueTask DisposeAsync()

Returns

ValueTask

A task that completes when context disposal finishes.

Equals(IPlayer?)

Determines whether another player has the same stable player hash code.

public bool Equals(IPlayer? other)

Parameters

other IPlayer?

The player to compare, or null.

Returns

bool

true when both players have the same stable hash code; otherwise, false.

ToString()

Returns the authenticated profile name when available, otherwise the captured remote endpoint.

public override string ToString()

Returns

string

The profile username or remote endpoint text.