Class ConnectionEstablishEvent

java.lang.Object
com.btcvelocity.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.

  • Constructor Details

    • ConnectionEstablishEvent

      public ConnectionEstablishEvent(@NonNull InboundConnection connection, @Nullable HandshakeIntent intention)
      Constructs a new ConnectionEstablishEvent.
      Parameters:
      connection - the inbound connection being established, must not be null
      intention - the handshake intention of the client, or null if not yet determined
      Throws:
      NullPointerException - if connection is null
  • Method Details

    • getConnection

      public @NonNull InboundConnection getConnection()
      Gets the inbound connection that is in the process of being established.
      Returns:
      the inbound connection
    • getIntention

      public @Nullable HandshakeIntent 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 null if not yet determined
    • getResult

      public ResultedEvent.GenericResult getResult()
      Returns the current result of this event. By default, connections are allowed.
      Specified by:
      getResult in interface ResultedEvent<ResultedEvent.GenericResult>
      Returns:
      the event result
    • setResult

      public void setResult(@NonNull ResultedEvent.GenericResult result)
      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:
      setResult in interface ResultedEvent<ResultedEvent.GenericResult>
      Parameters:
      result - the new result to apply, must not be null
      Throws:
      NullPointerException - if result is null