PlayerSetupConnectEvent
Package:
com.hypixel.hytale.server.core.event.events.playerImplements:IEvent<Void>,ICancellableCancellable: Yes
Standard event dispatched during early connection setup, after authentication completes but before a player entity is created. This is the earliest point at which a plugin can inspect or reject an incoming connection. Cancelling this event disconnects the player with the configurable reason message.
This event also supports server-to-server referrals via referToServer().
Fields / Accessors
Section titled “Fields / Accessors”| Field | Type | Accessor | Mutable | Nullable |
|---|---|---|---|---|
packetHandler | PacketHandler | getPacketHandler() | No | No |
username | String | getUsername() | No | No |
uuid | UUID | getUuid() | No | No |
auth | PlayerAuthentication | getAuth() | No | No |
referralData | byte[] | getReferralData() | No | Yes |
referralSource | HostAddress | getReferralSource() | No | Yes |
reason | String | getReason() | Yes | No |
clientReferral | ClientReferral | getClientReferral() | No | Yes |
- packetHandler — The packet handler for this connection.
- username — The connecting player’s username.
- uuid — The connecting player’s UUID.
- auth — Authentication data for the connecting player.
- referralData — Referral payload from the originating server.
nullif not a referral connection. - referralSource — Network address of the server that referred this player.
nullif not a referral connection. - reason — Disconnect reason shown to the player if the event is cancelled. Default:
"You have been disconnected from the server!". Mutable viasetReason(String). - clientReferral — Client-side referral information.
nulluntilreferToServer()is called.
Methods
Section titled “Methods”referToServer(String host, int port)
Section titled “referToServer(String host, int port)”Redirects the connecting player to another server. Maximum 4096 bytes referral data.
referToServer(String host, int port, byte[] data)
Section titled “referToServer(String host, int port, byte[] data)”Redirects with custom referral data payload.
isReferralConnection()
Section titled “isReferralConnection()”Returns true if this connection was referred from another server.
Fired By
Section titled “Fired By”SetupPacketHandler(line 123) viaeventBus dispatchFor— EventBus dispatch during early connection (before player entity exists).
Listening
Section titled “Listening”getEventRegistry().register(PlayerSetupConnectEvent.class, event -> { if (isBanned(event.getUuid())) { event.setReason("You are banned from this server."); event.setCancelled(true); }});Related Events
Section titled “Related Events”PlayerSetupDisconnectEvent— Fired when a player disconnects during the setup phase.PlayerConnectEvent— Fired after this event, once the player entity has been created.
Connection Flow
Section titled “Connection Flow”PlayerSetupConnectEvent --> PlayerConnectEvent --> AddPlayerToWorldEvent --> PlayerReadyEvent