Added ListenerBoundEvent and ListenerCloseEvent. (#454)
This commit is contained in:
@@ -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
|
||||
+ '}';
|
||||
}
|
||||
}
|
@@ -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
|
||||
+ '}';
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user