Added ListenerBoundEvent and ListenerCloseEvent. (#454)

This commit is contained in:
Cubxity
2021-04-02 17:24:45 +00:00
committed by GitHub
parent c34aee76ae
commit 5ea6728d1a
5 changed files with 186 additions and 7 deletions

View File

@@ -0,0 +1,42 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.proxy;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.network.ListenerType;
import java.net.InetSocketAddress;
/**
* This event is fired by the proxy after a listener starts accepting connections.
*/
public final class ListenerBoundEvent {
private final InetSocketAddress address;
private final ListenerType listenerType;
public ListenerBoundEvent(InetSocketAddress address, ListenerType listenerType) {
this.address = Preconditions.checkNotNull(address, "address");
this.listenerType = Preconditions.checkNotNull(listenerType, "listenerType");
}
public InetSocketAddress getAddress() {
return address;
}
public ListenerType getListenerType() {
return listenerType;
}
@Override
public String toString() {
return "ListenerBoundEvent{"
+ "address=" + address
+ ", listenerType=" + listenerType
+ '}';
}
}

View File

@@ -0,0 +1,42 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.proxy;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.network.ListenerType;
import java.net.InetSocketAddress;
/**
* This event is fired by the proxy before the proxy stops accepting connections.
*/
public final class ListenerCloseEvent {
private final InetSocketAddress address;
private final ListenerType listenerType;
public ListenerCloseEvent(InetSocketAddress address, ListenerType listenerType) {
this.address = Preconditions.checkNotNull(address, "address");
this.listenerType = Preconditions.checkNotNull(listenerType, "listenerType");
}
public InetSocketAddress getAddress() {
return address;
}
public ListenerType getListenerType() {
return listenerType;
}
@Override
public String toString() {
return "ListenerCloseEvent{"
+ "address=" + address
+ ", listenerType=" + listenerType
+ '}';
}
}

View File

@@ -0,0 +1,27 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.network;
/**
* Represents each listener type.
*/
public enum ListenerType {
MINECRAFT("Minecraft"),
QUERY("Query");
final String name;
ListenerType(final String name) {
this.name = name;
}
@Override
public String toString() {
return this.name;
}
}