PlayerPreLoginEvent
Namespace Mc.Scripting.Events · Kind struct (ref)
public ref struct PlayerPreLoginEvent : IEventA 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.
Constructors
Section titled “Constructors”| Member | Description |
|---|---|
Constructor |
Creates the event (for firing it from a plugin; native code builds its own). |
Constructor
Section titled “Constructor”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 |
Properties
Section titled “Properties”| 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. |
Address
Section titled “Address”public Utf8String Address { get; }Client address.
Cancelled
Section titled “Cancelled”public bool Cancelled { get; set; }Cancelling stops lower-priority handlers (unless they opt in) and the action itself.
Connection
Section titled “Connection”public ulong Connection { get; }Connection id.
Deferrals
Section titled “Deferrals”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.
KickMessage
Section titled “KickMessage”public Component KickMessage { get; }Shown to the client when the login is cancelled (default: a generic message). (parsed on access; allocates).
KickMessageJson
Section titled “KickMessageJson”public Utf8String KickMessageJson { get; }Shown to the client when the login is cancelled (default: a generic message). as JSON text (borrowed).
Username
Section titled “Username”public Utf8String Username { get; }The profile name.
public Uuid Uuid { get; }The authenticated profile id.
CatalogueId
Section titled “CatalogueId”public static ushort CatalogueId { get; }Catalogue id (stable ABI).
IsCancellable
Section titled “IsCancellable”public static bool IsCancellable { get; }Whether handlers can cancel the event.
public static string Key { get; }Registry key of the event.
Methods
Section titled “Methods”| 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.
SetKickMessage
Section titled “SetKickMessage”public void SetKickMessage(Component value)Replaces PlayerPreLoginEvent.KickMessage; an empty component clears it where the event says so.
Parameters
| Name | Type | Description |
|---|---|---|
value |
Component |
See also
Section titled “See also”Component · IEvent · LoginDeferral · Utf8String · Uuid