Skip to content

PlayerConnectEvent

Package: com.hypixel.hytale.server.core.event.events.player Implements: IEvent<Void> Cancellable: No

Standard event dispatched when a player entity has been created and connected to the server. This fires after the setup phase is complete (after PlayerSetupConnectEvent) and provides access to the player’s entity holder and reference.

The world field is mutable, allowing listeners to override which world the player initially spawns into. If set to null, the server uses its default world selection logic.

FieldTypeAccessorMutableNullable
holderHolder<EntityStore>getHolder()NoNo
playerRefPlayerRefgetPlayerRef()NoNo
playerPlayergetPlayer()NoNo
worldWorldgetWorld()YesYes
  • holder — The entity holder for the connecting player’s ECS store.
  • playerRef — Reference to the connected player, usable for sending messages and tracking identity.
  • player — The Player component. Deprecated — use holder.getComponent(Player.getComponentType()) instead.
  • world — The world the player will be placed in. May be null. Mutable via setWorld(@Nullable World) — changing this redirects the player’s initial world.
  • Universe (line 697) via eventBus dispatchFor — EventBus dispatch when player entity is created and connected.
getEventRegistry().register(PlayerConnectEvent.class, event -> {
PlayerRef playerRef = event.getPlayerRef();
World world = event.getWorld();
// Example: redirect all players to a specific world
if (world == null) {
event.setWorld(myDefaultWorld);
}
});
PlayerSetupConnectEvent --> PlayerConnectEvent --> AddPlayerToWorldEvent --> PlayerReadyEvent