Class ServerPreConnectEvent
java.lang.Object
com.velocitypowered.api.event.player.ServerPreConnectEvent
- All Implemented Interfaces:
ResultedEvent<ServerPreConnectEvent.ServerResult>
@AwaitingEvent
public final class ServerPreConnectEvent
extends Object
implements ResultedEvent<ServerPreConnectEvent.ServerResult>
This event is fired before the player connects to a server. Velocity will wait on this event to
finish firing before initiating the connection.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Represents the result of theServerPreConnectEvent
.Nested classes/interfaces inherited from interface com.velocitypowered.api.event.ResultedEvent
ResultedEvent.ComponentResult, ResultedEvent.GenericResult, ResultedEvent.Result
-
Constructor Summary
ConstructorDescriptionServerPreConnectEvent
(Player player, RegisteredServer originalServer) Creates the ServerPreConnectEvent.ServerPreConnectEvent
(Player player, RegisteredServer originalServer, @Nullable RegisteredServer previousServer) Creates the ServerPreConnectEvent. -
Method Summary
Modifier and TypeMethodDescriptionReturns the server that the player originally tried to connect to.Returns the player connecting to the server.@Nullable RegisteredServer
Returns the server that the player is currently connected to.Returns the result associated with this event.void
Sets the result of this event.toString()
-
Constructor Details
-
ServerPreConnectEvent
Creates the ServerPreConnectEvent.- Parameters:
player
- the player who is connecting to a serveroriginalServer
- the server the player was trying to connect to
-
ServerPreConnectEvent
public ServerPreConnectEvent(Player player, RegisteredServer originalServer, @Nullable RegisteredServer previousServer) Creates the ServerPreConnectEvent.- Parameters:
player
- the player who is connecting to a serveroriginalServer
- the server the player was trying to connect topreviousServer
- the server the player is connected to
-
-
Method Details
-
getPlayer
Returns the player connecting to the server.- Returns:
- the player connecting to the server
-
getResult
Description copied from interface:ResultedEvent
Returns the result associated with this event.- Specified by:
getResult
in interfaceResultedEvent<ServerPreConnectEvent.ServerResult>
- Returns:
- the result of this event
-
setResult
Description copied from interface:ResultedEvent
Sets the result of this event. The result must be non-null.- Specified by:
setResult
in interfaceResultedEvent<ServerPreConnectEvent.ServerResult>
- Parameters:
result
- the new result
-
getOriginalServer
Returns the server that the player originally tried to connect to. To get the server the player will connect to, see theServerPreConnectEvent.ServerResult
of this event. To get the server the player is currently on when this event is fired, usegetPreviousServer()
.- Returns:
- the server that the player originally tried to connect to
-
getPreviousServer
Returns the server that the player is currently connected to. Prefer this method over usingPlayer.getCurrentServer()
as the current server might get reset after server kicks to prevent connection issues. This isnull
if they were not connected to another server beforehand (for instance, if the player has just joined the proxy).- Returns:
- the server the player is currently connected to.
-
toString
-