Class WorkerBeforeJoinEvent

Emitted before a player successfully or unsuccessfully joins a room on the server.

This event allows you to redirect the player to another game, or to completely prevent them from joining.

A better event to use for when a player has successfully joined a room is the player.join event.

Example

.@EventListener("worker.beforejoin")
onWorkerBeforeJoin(ev: WorkerBeforeJoinEvent) {
for (const [ netId, mod ] of ev.client.mods) {
if (mod.modid === "com.andruzzzhka.customserversclient") {
ev.cancel();
return ev.client.disconnect("Do not join with custom servers client!!!");
}
}
}

Hierarchy

  • CancelableEvent
    • WorkerBeforeJoinEvent

Properties

eventName: "worker.beforejoin" = ...
canceled: boolean
client: Connection

The client that is attempting to join the room.

eventName: "worker.beforejoin" = ...
foundRoom: undefined | Room

The room that was found, or undefined if there is no room on the server with the code.

gameCode: number

The game code that the player used to search for a room.

Accessors

Methods

  • Returns void

  • Change the room that the player will join.

    Parameters

    • room: undefined | Room

      The room that the player will join instead, set to undefined to give the player a "Game Not Found" error.

    Returns void

Constructors

Generated using TypeDoc