Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-12-23 23:00:35 +01:00
Fix issues with server connections.
Dieser Commit ist enthalten in:
Ursprung
2b53d14461
Commit
f423169449
@ -4,8 +4,10 @@ import com.google.common.base.Preconditions;
|
||||
import com.velocitypowered.api.event.ResultedEvent;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import java.util.Optional;
|
||||
import net.kyori.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
/**
|
||||
* Fired when a player is kicked from a server. You may either allow Velocity to kick the player
|
||||
@ -16,15 +18,15 @@ public final class KickedFromServerEvent implements
|
||||
|
||||
private final Player player;
|
||||
private final RegisteredServer server;
|
||||
private final Component originalReason;
|
||||
private final @Nullable Component originalReason;
|
||||
private final boolean duringServerConnect;
|
||||
private ServerKickResult result;
|
||||
|
||||
public KickedFromServerEvent(Player player, RegisteredServer server, Component originalReason,
|
||||
boolean duringServerConnect, Component fancyReason) {
|
||||
public KickedFromServerEvent(Player player, RegisteredServer server,
|
||||
@Nullable Component originalReason, boolean duringServerConnect, Component fancyReason) {
|
||||
this.player = Preconditions.checkNotNull(player, "player");
|
||||
this.server = Preconditions.checkNotNull(server, "server");
|
||||
this.originalReason = Preconditions.checkNotNull(originalReason, "originalReason");
|
||||
this.originalReason = originalReason;
|
||||
this.duringServerConnect = duringServerConnect;
|
||||
this.result = new Notify(fancyReason);
|
||||
}
|
||||
@ -47,8 +49,8 @@ public final class KickedFromServerEvent implements
|
||||
return server;
|
||||
}
|
||||
|
||||
public Component getOriginalReason() {
|
||||
return originalReason;
|
||||
public Optional<Component> getOriginalReason() {
|
||||
return Optional.ofNullable(originalReason);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -324,7 +324,8 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
||||
joinGame.getLevelType()));
|
||||
}
|
||||
|
||||
// Remove old boss bars. These don't get cleared when sending JoinGame so we need to track these.
|
||||
// Remove previous boss bars. These don't get cleared when sending JoinGame, thus the need to
|
||||
// track them.
|
||||
for (UUID serverBossBar : serverBossBars) {
|
||||
BossBar deletePacket = new BossBar();
|
||||
deletePacket.setUuid(serverBossBar);
|
||||
|
@ -350,11 +350,9 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
} else {
|
||||
connection.closeWith(Disconnect.create(friendlyReason));
|
||||
}
|
||||
} else if (kickReason != null) {
|
||||
// Already connected to the server being disconnected from.
|
||||
} else {
|
||||
KickedFromServerEvent originalEvent = new KickedFromServerEvent(this, rs, kickReason,
|
||||
!connectedServer.getServer().equals(rs), friendlyReason);
|
||||
|
||||
server.getEventManager().fire(originalEvent)
|
||||
.thenAcceptAsync(event -> {
|
||||
if (event.getResult() instanceof DisconnectPlayer) {
|
||||
@ -375,8 +373,6 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
connection.closeWith(Disconnect.create(friendlyReason));
|
||||
}
|
||||
}, connection.eventLoop());
|
||||
} else {
|
||||
connection.closeWith(Disconnect.create(friendlyReason));
|
||||
}
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren