|
| 1 | +/* |
| 2 | + * Copyright (C) 2018-2021 Velocity Contributors |
| 3 | + * |
| 4 | + * The Velocity API is licensed under the terms of the MIT License. For more details, |
| 5 | + * reference the LICENSE file in the api top-level directory. |
| 6 | + */ |
| 7 | + |
| 8 | +package com.velocitypowered.api.event.connection; |
| 9 | + |
| 10 | +import com.google.common.base.Preconditions; |
| 11 | +import com.velocitypowered.api.event.ResultedEvent; |
| 12 | +import com.velocitypowered.api.event.annotation.AwaitingEvent; |
| 13 | +import com.velocitypowered.api.proxy.InboundConnection; |
| 14 | +import org.jetbrains.annotations.NotNull; |
| 15 | + |
| 16 | +/** |
| 17 | + * Event called when a connection is initially established with the proxy. |
| 18 | + * Velocity will wait for this event to fire before continuing with the connection. |
| 19 | + */ |
| 20 | +@AwaitingEvent |
| 21 | +public class ConnectionEstablishEvent implements ResultedEvent<ResultedEvent.GenericResult> { |
| 22 | + private final InboundConnection connection; |
| 23 | + private GenericResult result = GenericResult.allowed(); |
| 24 | + |
| 25 | + public ConnectionEstablishEvent(final @NotNull InboundConnection connection) { |
| 26 | + this.connection = Preconditions.checkNotNull(connection, "connection"); |
| 27 | + } |
| 28 | + |
| 29 | + /** |
| 30 | + * Returns the inbound connection that is being established. |
| 31 | + * @return the connection |
| 32 | + */ |
| 33 | + public @NotNull InboundConnection getConnection() { |
| 34 | + return this.connection; |
| 35 | + } |
| 36 | + |
| 37 | + @Override |
| 38 | + public GenericResult getResult() { |
| 39 | + return this.result; |
| 40 | + } |
| 41 | + |
| 42 | + @Override |
| 43 | + public void setResult(final @NotNull GenericResult result) { |
| 44 | + this.result = Preconditions.checkNotNull(result, "result"); |
| 45 | + } |
| 46 | +} |
0 commit comments