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
Nested Classes Modifier and Type Class Description static classServerPreConnectEvent.ServerResultRepresents the result of theServerPreConnectEvent.-
Nested classes/interfaces inherited from interface com.velocitypowered.api.event.ResultedEvent
ResultedEvent.ComponentResult, ResultedEvent.GenericResult, ResultedEvent.Result
-
-
Constructor Summary
Constructors Constructor Description ServerPreConnectEvent(Player player, RegisteredServer originalServer)Creates the ServerPreConnectEvent.ServerPreConnectEvent(Player player, RegisteredServer originalServer, @Nullable RegisteredServer previousServer)Creates the ServerPreConnectEvent.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RegisteredServergetOriginalServer()Returns the server that the player originally tried to connect to.PlayergetPlayer()Returns the player connecting to the server.@Nullable RegisteredServergetPreviousServer()Returns the server that the player is currently connected to.ServerPreConnectEvent.ServerResultgetResult()Returns the result associated with this event.voidsetResult(ServerPreConnectEvent.ServerResult result)Sets the result of this event.StringtoString()
-
-
-
Constructor Detail
-
ServerPreConnectEvent
public ServerPreConnectEvent(Player player, RegisteredServer originalServer)
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 ís connected to
-
-
Method Detail
-
getPlayer
public Player getPlayer()
Returns the player connecting to the server.- Returns:
- the player connecting to the server
-
getResult
public ServerPreConnectEvent.ServerResult getResult()
Description copied from interface:ResultedEventReturns the result associated with this event.- Specified by:
getResultin interfaceResultedEvent<ServerPreConnectEvent.ServerResult>- Returns:
- the result of this event
-
setResult
public void setResult(ServerPreConnectEvent.ServerResult result)
Description copied from interface:ResultedEventSets the result of this event. The result must be non-null.- Specified by:
setResultin interfaceResultedEvent<ServerPreConnectEvent.ServerResult>- Parameters:
result- the new result
-
getOriginalServer
public RegisteredServer getOriginalServer()
Returns the server that the player originally tried to connect to. To get the server the player will connect to, see theServerPreConnectEvent.ServerResultof 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
public @Nullable RegisteredServer 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 isnullif 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.
-
-