3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Expose original server in ServerPreConnectEvent

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-09-15 01:16:26 -04:00
Ursprung e9568e1b6c
Commit 2b1d55a0fc
2 geänderte Dateien mit 10 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -14,11 +14,13 @@ import java.util.Optional;
*/ */
public class ServerPreConnectEvent implements ResultedEvent<ServerPreConnectEvent.ServerResult> { public class ServerPreConnectEvent implements ResultedEvent<ServerPreConnectEvent.ServerResult> {
private final Player player; private final Player player;
private final ServerInfo originalServer;
private ServerResult result; private ServerResult result;
public ServerPreConnectEvent(Player player, ServerResult result) { public ServerPreConnectEvent(Player player, ServerInfo originalServer) {
this.player = Preconditions.checkNotNull(player, "player"); this.player = Preconditions.checkNotNull(player, "player");
this.result = Preconditions.checkNotNull(result, "result"); this.originalServer = Preconditions.checkNotNull(originalServer, "originalServer");
this.result = ServerResult.allowed(originalServer);
} }
public Player getPlayer() { public Player getPlayer() {
@ -35,10 +37,15 @@ public class ServerPreConnectEvent implements ResultedEvent<ServerPreConnectEven
this.result = Preconditions.checkNotNull(result, "result"); this.result = Preconditions.checkNotNull(result, "result");
} }
public ServerInfo getOriginalServer() {
return originalServer;
}
@Override @Override
public String toString() { public String toString() {
return "ServerPreConnectEvent{" + return "ServerPreConnectEvent{" +
"player=" + player + "player=" + player +
", originalServer=" + originalServer +
", result=" + result + ", result=" + result +
'}'; '}';
} }

Datei anzeigen

@ -275,7 +275,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
} }
// Otherwise, initiate the connection. // Otherwise, initiate the connection.
ServerPreConnectEvent event = new ServerPreConnectEvent(this, ServerPreConnectEvent.ServerResult.allowed(request.getServer())); ServerPreConnectEvent event = new ServerPreConnectEvent(this, request.getServer());
return server.getEventManager().fire(event) return server.getEventManager().fire(event)
.thenCompose((newEvent) -> { .thenCompose((newEvent) -> {
if (!newEvent.getResult().isAllowed()) { if (!newEvent.getResult().isAllowed()) {