Skip to content

PlayerSetupConnectEvent

Package: com.hypixel.hytale.server.core.event.events.player Implements: IEvent<Void>, ICancellable Cancellable: 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().

FieldTypeAccessorMutableNullable
packetHandlerPacketHandlergetPacketHandler()NoNo
usernameStringgetUsername()NoNo
uuidUUIDgetUuid()NoNo
authPlayerAuthenticationgetAuth()NoNo
referralDatabyte[]getReferralData()NoYes
referralSourceHostAddressgetReferralSource()NoYes
reasonStringgetReason()YesNo
clientReferralClientReferralgetClientReferral()NoYes
  • 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. null if not a referral connection.
  • referralSource — Network address of the server that referred this player. null if 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 via setReason(String).
  • clientReferral — Client-side referral information. null until referToServer() is called.

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.

Returns true if this connection was referred from another server.

  • SetupPacketHandler (line 123) via eventBus dispatchFor — EventBus dispatch during early connection (before player entity exists).
getEventRegistry().register(PlayerSetupConnectEvent.class, event -> {
if (isBanned(event.getUuid())) {
event.setReason("You are banned from this server.");
event.setCancelled(true);
}
});
PlayerSetupConnectEvent --> PlayerConnectEvent --> AddPlayerToWorldEvent --> PlayerReadyEvent