mirror of https://github.com/GeyserMC/Geyser.git
Make ProxyIp nullable
This commit is contained in:
parent
45d8466f84
commit
878ab94257
|
@ -26,6 +26,7 @@
|
|||
package org.geysermc.geyser.api.event.connection;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.geysermc.event.Cancellable;
|
||||
import org.geysermc.event.Event;
|
||||
|
||||
|
@ -40,7 +41,7 @@ public final class ConnectionRequestEvent implements Event, Cancellable {
|
|||
private final InetSocketAddress ip;
|
||||
private final InetSocketAddress proxyIp;
|
||||
|
||||
public ConnectionRequestEvent(@NonNull InetSocketAddress ip, @NonNull InetSocketAddress proxyIp) {
|
||||
public ConnectionRequestEvent(@NonNull InetSocketAddress ip, @Nullable InetSocketAddress proxyIp) {
|
||||
this.ip = ip;
|
||||
this.proxyIp = proxyIp;
|
||||
}
|
||||
|
@ -54,9 +55,9 @@ public final class ConnectionRequestEvent implements Event, Cancellable {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return the IP address of the proxy handling the connection, if available, otherwise also the client IP.
|
||||
* @return the IP address of the proxy handling the connection, otherwise null if there is no proxy.
|
||||
*/
|
||||
@NonNull
|
||||
@Nullable
|
||||
public InetSocketAddress getProxyIp() {
|
||||
return proxyIp;
|
||||
}
|
||||
|
|
|
@ -235,7 +235,7 @@ public final class GeyserServer {
|
|||
ip = "<IP address withheld>";
|
||||
}
|
||||
|
||||
ConnectionRequestEvent requestEvent = new ConnectionRequestEvent(inetSocketAddress, this.proxiedAddresses.getOrDefault(inetSocketAddress, inetSocketAddress));
|
||||
ConnectionRequestEvent requestEvent = new ConnectionRequestEvent(inetSocketAddress, this.proxiedAddresses.get(inetSocketAddress));
|
||||
geyser.eventBus().fire(requestEvent);
|
||||
if (requestEvent.isCancelled()) {
|
||||
geyser.getLogger().debug("Connection request from " + ip + " was cancelled using the API!");
|
||||
|
|
Loading…
Reference in New Issue