Class ConnectionEstablishEvent
java.lang.Object
com.velocitypowered.api.event.connection.ConnectionEstablishEvent
- All Implemented Interfaces:
ResultedEvent<ResultedEvent.GenericResult>
@AwaitingEvent
public class ConnectionEstablishEvent
extends Object
implements ResultedEvent<ResultedEvent.GenericResult>
This event is fired when a new connection is initially established with the proxy.
Unlike most events, this event is marked with AwaitingEvent, which means Velocity
will block connection progression until all event handlers have completed. This provides
an opportunity to validate or reject the connection before the login sequence begins.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.velocitypowered.api.event.ResultedEvent
ResultedEvent.ComponentResult, ResultedEvent.GenericResult, ResultedEvent.Result -
Constructor Summary
ConstructorsConstructorDescriptionConnectionEstablishEvent(@NonNull InboundConnection connection, @Nullable HandshakeIntent intention) Constructs a newConnectionEstablishEvent. -
Method Summary
Modifier and TypeMethodDescription@NonNull InboundConnectionGets the inbound connection that is in the process of being established.@Nullable HandshakeIntentGets the handshake intention of the client.Returns the current result of this event.voidsetResult(@NonNull ResultedEvent.GenericResult result) Sets the result of this event.
-
Constructor Details
-
ConnectionEstablishEvent
public ConnectionEstablishEvent(@NonNull InboundConnection connection, @Nullable HandshakeIntent intention) Constructs a newConnectionEstablishEvent.- Parameters:
connection- the inbound connection being established, must not be nullintention- the handshake intention of the client, ornullif not yet determined- Throws:
NullPointerException- ifconnectionis null
-
-
Method Details
-
getConnection
Gets the inbound connection that is in the process of being established.- Returns:
- the inbound connection
-
getIntention
Gets the handshake intention of the client. The intention may indicate, for example, whether the client is attempting to log in or request the server list.- Returns:
- the handshake intention, or
nullif not yet determined
-
getResult
Returns the current result of this event. By default, connections are allowed.- Specified by:
getResultin interfaceResultedEvent<ResultedEvent.GenericResult>- Returns:
- the event result
-
setResult
Sets the result of this event. Use this to allow or deny the connection.If a connection is denied, the client will be immediately disconnected.
- Specified by:
setResultin interfaceResultedEvent<ResultedEvent.GenericResult>- Parameters:
result- the new result to apply, must not be null- Throws:
NullPointerException- ifresultis null
-