13
0
geforkt von Mirrors/Velocity

Add previous server to ServerConnectedEvent

Dieser Commit ist enthalten in:
Gabik21 2019-08-31 17:07:38 +02:00
Ursprung e191577afb
Commit 7c0a402cca
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: A95DB353715365DF
2 geänderte Dateien mit 12 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -3,6 +3,8 @@ package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.Player;
import com.velocitypowered.api.proxy.server.RegisteredServer;
import java.util.Optional;
import org.checkerframework.checker.nullness.qual.Nullable;
/**
* This event is fired once the player has successfully connected to the target server and the
@ -12,10 +14,13 @@ public final class ServerConnectedEvent {
private final Player player;
private final RegisteredServer server;
private final @Nullable RegisteredServer previousServer;
public ServerConnectedEvent(Player player, RegisteredServer server) {
public ServerConnectedEvent(Player player, RegisteredServer server,
@Nullable RegisteredServer previousServer) {
this.player = Preconditions.checkNotNull(player, "player");
this.server = Preconditions.checkNotNull(server, "server");
this.previousServer = previousServer;
}
public Player getPlayer() {
@ -26,6 +31,10 @@ public final class ServerConnectedEvent {
return server;
}
public Optional<RegisteredServer> getPreviousServer() {
return Optional.ofNullable(previousServer);
}
@Override
public String toString() {
return "ServerConnectedEvent{"

Datei anzeigen

@ -80,7 +80,8 @@ public class TransitionSessionHandler implements MinecraftSessionHandler {
// The goods are in hand! We got JoinGame. Let's transition completely to the new state.
smc.setAutoReading(false);
server.getEventManager()
.fire(new ServerConnectedEvent(serverConn.getPlayer(), serverConn.getServer()))
.fire(new ServerConnectedEvent(serverConn.getPlayer(), serverConn.getServer(),
existingConnection != null ? existingConnection.getServer() : null))
.whenCompleteAsync((x, error) -> {
// Strap on the ClientPlaySessionHandler if required.
ClientPlaySessionHandler playHandler;