Unverified Commit c9f3aa68 authored by Minseong Choi's avatar Minseong Choi 💬
Browse files

fix(velocity): stop the lobby tile failing for players already in the lobby

Asking for the server you are standing on is a no-op, but it went through the
whole wake-and-queue path and ended in a Connect to the current server, which
Velocity answers ALREADY_CONNECTED. The player saw a failure for a move that
was never real.

The guard belongs in authorizeAndWait rather than at each entry point: the
menu tile, /felis go and an accepted invite all funnel through it. The lobby
is where it shows up most, since the tile for the lobby itself sits in front
of every player already standing in it.
parent 8480387c
Loading
Loading
Loading
Loading
+15 −0
Changes for plugins/velocity/src/main/java/best/lolicon/felis/velocity/WaitingRouter.java: 15 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -359,6 +359,21 @@ public final class WaitingRouter {
                                  boolean joinIfReady) {
        UUID id = player.getUniqueId();
        boolean zh = FelisVelocityPlugin.zh(player);
        // Asking for the server you are standing on is a no-op, and it has to be caught
        // here rather than at each entry point: the menu tile, /felis go and an accepted
        // invite all funnel through this method. Without the guard the request runs the
        // whole wake-and-queue path and ends in a Connect to the current server, which
        // Velocity answers ALREADY_CONNECTED — the player sees a failure for something
        // that was never a real move. Cheapest for the lobby, where the tile for the
        // lobby itself sits in front of every player who is already in it.
        if (player.getCurrentServer()
                .map(sc -> sc.getServerInfo().getName().equalsIgnoreCase(serverName))
                .orElse(false)) {
            player.sendMessage(Component.text(
                    zh ? "你已经在「" + serverName + "」了。"
                       : "You're already on « " + serverName + " ».", NamedTextColor.YELLOW));
            return;
        }
        plugin.async(() -> {
            try {
                if (!api.linkStatus(id)) {