geforkt von Mirrors/Velocity
Call DisconnectEvent explicitly instead of relying on ConnectedPlayer#teardown() to do it for us
Should fix (but not verified) #289
Dieser Commit ist enthalten in:
Ursprung
669bd14779
Commit
8b8fd284b3
@ -104,6 +104,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
private final CompletableFuture<Void> teardownFuture = new CompletableFuture<>();
|
private final CompletableFuture<Void> teardownFuture = new CompletableFuture<>();
|
||||||
|
|
||||||
private @MonotonicNonNull List<String> serversToTry = null;
|
private @MonotonicNonNull List<String> serversToTry = null;
|
||||||
|
private boolean explicitlyDisconnected = false;
|
||||||
|
|
||||||
ConnectedPlayer(VelocityServer server, GameProfile profile, MinecraftConnection connection,
|
ConnectedPlayer(VelocityServer server, GameProfile profile, MinecraftConnection connection,
|
||||||
@Nullable InetSocketAddress virtualHost, boolean onlineMode) {
|
@Nullable InetSocketAddress virtualHost, boolean onlineMode) {
|
||||||
@ -281,9 +282,20 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnect(Component reason) {
|
public void disconnect(Component reason) {
|
||||||
|
if (connection.eventLoop().inEventLoop()) {
|
||||||
|
disconnect0(reason, false);
|
||||||
|
} else {
|
||||||
|
connection.eventLoop().execute(() -> disconnect0(reason, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disconnect0(Component reason, boolean duringLogin) {
|
||||||
logger.info("{} has disconnected: {}", this,
|
logger.info("{} has disconnected: {}", this,
|
||||||
LegacyComponentSerializer.legacy().serialize(reason));
|
LegacyComponentSerializer.legacy().serialize(reason));
|
||||||
|
this.explicitlyDisconnected = true;
|
||||||
connection.closeWith(Disconnect.create(reason));
|
connection.closeWith(Disconnect.create(reason));
|
||||||
|
|
||||||
|
server.getEventManager().fireAndForget(new DisconnectEvent(this, duringLogin));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -574,10 +586,11 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
connectedServer.disconnect();
|
connectedServer.disconnect();
|
||||||
}
|
}
|
||||||
boolean isConnected = server.getPlayer(this.getUniqueId()).isPresent();
|
boolean isConnected = server.getPlayer(this.getUniqueId()).isPresent();
|
||||||
|
|
||||||
server.unregisterConnection(this);
|
server.unregisterConnection(this);
|
||||||
server.getEventManager().fire(new DisconnectEvent(this, !isConnected))
|
if (!this.explicitlyDisconnected) {
|
||||||
.thenRun(() -> this.teardownFuture.complete(null));
|
server.getEventManager().fire(new DisconnectEvent(this, !isConnected))
|
||||||
|
.thenRun(() -> this.teardownFuture.complete(null));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompletableFuture<Void> getTeardownFuture() {
|
public CompletableFuture<Void> getTeardownFuture() {
|
||||||
|
@ -204,7 +204,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
inbound.getVirtualHost().orElse(null), onlineMode);
|
inbound.getVirtualHost().orElse(null), onlineMode);
|
||||||
this.connectedPlayer = player;
|
this.connectedPlayer = player;
|
||||||
if (!server.canRegisterConnection(player)) {
|
if (!server.canRegisterConnection(player)) {
|
||||||
player.disconnect(VelocityMessages.ALREADY_CONNECTED);
|
player.disconnect0(VelocityMessages.ALREADY_CONNECTED, true);
|
||||||
return CompletableFuture.completedFuture(null);
|
return CompletableFuture.completedFuture(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,10 +246,10 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
|
|
||||||
Optional<Component> reason = event.getResult().getReason();
|
Optional<Component> reason = event.getResult().getReason();
|
||||||
if (reason.isPresent()) {
|
if (reason.isPresent()) {
|
||||||
player.disconnect(reason.get());
|
player.disconnect0(reason.get(), true);
|
||||||
} else {
|
} else {
|
||||||
if (!server.registerConnection(player)) {
|
if (!server.registerConnection(player)) {
|
||||||
player.disconnect(VelocityMessages.ALREADY_CONNECTED);
|
player.disconnect0(VelocityMessages.ALREADY_CONNECTED, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
.thenRunAsync(() -> {
|
.thenRunAsync(() -> {
|
||||||
Optional<RegisteredServer> toTry = event.getInitialServer();
|
Optional<RegisteredServer> toTry = event.getInitialServer();
|
||||||
if (!toTry.isPresent()) {
|
if (!toTry.isPresent()) {
|
||||||
player.disconnect(VelocityMessages.NO_AVAILABLE_SERVERS);
|
player.disconnect0(VelocityMessages.NO_AVAILABLE_SERVERS, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.createConnectionRequest(toTry.get()).fireAndForget();
|
player.createConnectionRequest(toTry.get()).fireAndForget();
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren