Class PlayerChooseInitialServerEvent
java.lang.Object
com.velocitypowered.api.event.player.PlayerChooseInitialServerEvent
Fired when a player has finished the login process, and we need to choose the first server
to connect to. Velocity will wait on this event to finish firing before initiating the connection,
but you should try to limit the work done in this event. Failures will be handled by
KickedFromServerEvent as normal.-
Constructor Summary
ConstructorsConstructorDescriptionPlayerChooseInitialServerEvent(Player player, @Nullable RegisteredServer initialServer) Constructs a PlayerChooseInitialServerEvent. -
Method Summary
Modifier and TypeMethodDescriptionGets the initial server the player will connect to.Gets the player who is choosing the initial server.Returns the reason the player will be disconnected if no initial server is selected.voidsetInitialServer(@Nullable RegisteredServer server) Sets the new initial server.voidSets a custom disconnect reason for the player.toString()Returns a string representation of thisPlayerChooseInitialServerEvent.
-
Constructor Details
-
PlayerChooseInitialServerEvent
Constructs a PlayerChooseInitialServerEvent.- Parameters:
player- the player that was connectedinitialServer- the initial server selected, may benull
-
-
Method Details
-
getPlayer
Gets the player who is choosing the initial server.- Returns:
- the connected player
-
getInitialServer
Gets the initial server the player will connect to.- Returns:
- an
Optionalcontaining the selected server, or empty if none was set
-
setInitialServer
Sets the new initial server.- Parameters:
server- the initial server the player should connect to
-
getReason
Returns the reason the player will be disconnected if no initial server is selected.The proxy seeds this with a default human-readable message before firing the event, so this will usually be present. Plugins may override or clear it.
- Returns:
- the disconnect reason, or
Optional.empty()if a plugin explicitly cleared it (in which case the proxy will still fall back to its default message)
-
setReason
Sets a custom disconnect reason for the player.Passing
nullclears the custom reason. The proxy will then fall back to its default disconnect message if no initial server is ultimately selected.- Parameters:
reason- the disconnect reason to show to the player
-
toString
Returns a string representation of thisPlayerChooseInitialServerEvent.The output includes the player, the selected initial server (if any), and the disconnect reason (if set).
-