Skip to content

PlayerPreLoginEvent

Namespace Mc.Scripting.Events · Kind struct (ref)

public ref struct PlayerPreLoginEvent : IEvent

A client finished authentication and is about to enter the configuration phase. Handlers run on the TICK thread: a blocking call (a database or web lookup) freezes the whole server, so do not look anything up here. Cancel to refuse the login (set the kick message first), or call Defer() and answer later from Scheduler.RunAsync: the login waits up to 30 seconds, continues when every deferral allowed it and is refused as soon as one denies. A plugin that unloads releases its pending deferrals (counted as allowed).

Id 10
Key mc:player_pre_login
Cancellable yes
Fired by the engine yes
Field Type Handlers may write Description
Connection ulong no (readonly) Connection id.
Uuid Uuid no (readonly) The authenticated profile id.
Username Utf8String no (readonly) The profile name.
Address Utf8String no (readonly) Client address.
KickMessage component yes Shown to the client when the login is cancelled (default: a generic message).
Deferrals int no (readonly) How many plugins hold the login (each Defer() adds one): it continues when all of them allowed it, and any denial refuses it at once.

Set e.Cancelled = true in a handler to cancel it; lower-priority handlers are skipped unless they subscribed with receiveCancelled: true.

Member Description
Constructor Creates the event (for firing it from a plugin; native code builds its own).
public PlayerPreLoginEvent(ulong connection, Uuid uuid, Utf8String username, Utf8String address, Utf8String kickMessage, int deferrals)

Creates the event (for firing it from a plugin; native code builds its own). Signature of API 1.0.

Parameters

Name Type Description
connection ulong
uuid Uuid
username Utf8String
address Utf8String
kickMessage Utf8String
deferrals int
Member Description
Utf8String Address { get; } Client address.
bool Cancelled { get; set; } Cancelling stops lower-priority handlers (unless they opt in) and the action itself.
ulong Connection { get; } Connection id.
int Deferrals { get; } How many plugins hold the login (each Defer() adds one): it continues when all of them allowed it, and any denial refuses it at once.
Component KickMessage { get; } Shown to the client when the login is cancelled (default: a generic message).
Utf8String KickMessageJson { get; } Shown to the client when the login is cancelled (default: a generic message).
Utf8String Username { get; } The profile name.
Uuid Uuid { get; } The authenticated profile id.
static ushort CatalogueId { get; } Catalogue id (stable ABI).
static bool IsCancellable { get; } Whether handlers can cancel the event.
static string Key { get; } Registry key of the event.
public Utf8String Address { get; }

Client address.

public bool Cancelled { get; set; }

Cancelling stops lower-priority handlers (unless they opt in) and the action itself.

public ulong Connection { get; }

Connection id.

public int Deferrals { get; }

How many plugins hold the login (each Defer() adds one): it continues when all of them allowed it, and any denial refuses it at once.

public Component KickMessage { get; }

Shown to the client when the login is cancelled (default: a generic message). (parsed on access; allocates).

public Utf8String KickMessageJson { get; }

Shown to the client when the login is cancelled (default: a generic message). as JSON text (borrowed).

public Utf8String Username { get; }

The profile name.

public Uuid Uuid { get; }

The authenticated profile id.

public static ushort CatalogueId { get; }

Catalogue id (stable ABI).

public static bool IsCancellable { get; }

Whether handlers can cancel the event.

public static string Key { get; }

Registry key of the event.

Member Description
LoginDeferral Defer() Holds the login until the returned LoginDeferral is completed (up to the server’s login timeout, 30 seconds).
void SetKickMessage(Component value) Replaces PlayerPreLoginEvent.KickMessage; an empty component clears it where the event says so.
public LoginDeferral Defer()

Holds the login until the returned LoginDeferral is completed (up to the server’s login timeout, 30 seconds). Use it to decide asynchronously (database or web lookups): call Scheduler.RunAsync and complete the deferral from any thread. Cancelling the event instead refuses the login at once.

Returns LoginDeferral: The deferral to complete with LoginDeferral.Allow or LoginDeferral.Deny.

public void SetKickMessage(Component value)

Replaces PlayerPreLoginEvent.KickMessage; an empty component clears it where the event says so.

Parameters

Name Type Description
value Component

Component · IEvent · LoginDeferral · Utf8String · Uuid